<commit_before>package main

import (
	"fmt"
	"strings"
	"time"
)

type cli struct {
	pos   int
	total int

	lastDone      int
	lastUpdate    time.Time
	smoothedSpeed float64

	start time.Time
}

func newCLI(total int) *cli {
	return &cli{
		total: total,
		start: time.Now(),
	}
}

var posStrs = []string{`)`, `|`, `(`, `|`}

func (c *cli) update(done int) {

	doneDelta := done - c.lastDone
	c.lastDone = done
	now := time.Now()
	speed := float64(doneDelta) / now.Sub(c.lastUpdate).Seconds()
	const alpha = 0.01
	c.smoothedSpeed = alpha*speed + (1-alpha)*c.smoothedSpeed<commit_msg>Adjust how smoothedSpeed is calculated<commit_after>package main

import (
	"fmt"
	"strings"
	"time"
)

type cli struct {
	pos   int
	total int

	lastDone      int
	lastUpdate    time.Time
	smoothedSpeed float64

	start time.Time
}

func newCLI(total int) *cli {
	return &cli{
		total: total,
		start: time.Now(),
	}
}

var posStrs = []string{`)`, `|`, `(`, `|`}

func (c *cli) update(done int) {

	doneDelta := done - c.lastDone
	c.lastDone = done
	now := time.Now()
	elapsed := now.Sub(c.start)

	if now.Sub(c.start) > time.Second {
		speed := float64(doneDelta) / now.Sub(c.lastUpdate).Seconds()
		const alpha = 0.001
		c.smoothedSpeed = alpha*speed + (1-alpha)*c.smoothedSpeed
	} else {
		elapsedInSeconds := float64(elapsed) / float64(time.Second)
		c.smoothedSpeed = float64(done) / elapsedInSeconds
	}

{'fraction_non_alphanumeric': 0.15003589375448673, 'fraction_numerical': 0.016511127063890883, 'mean_word_length': 3.54071661237785, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2302499', 'n_tokens_mistral': 578, 'n_tokens_neox': 546, 'n_words': 125}