<commit_before>package run

import (
	"bufio"
	"fmt"
	"math/rand"
	"net/http"
	"os"
	"strconv"
	"strings"
	"sync"
	"time"
)

func secsToDuration(delay float64) time.Duration {
	return time.Duration(delay * 1000000000)
}

func calcRampUpPercentage(tStart time.Time, rampUpSecs int) float64 {
	tNow := time.Now()
	rampUpDuration := time.Duration(rampUpSecs) * time.Second
	tRampUpDone := tStart.Add(rampUpDuration)
	rampUpLeft := tRampUpDone.Sub(tNow)

	res := 1 - float64(rampUpLeft)/float64(rampUpDuration)
	if res > 1 {
		return 1
	} else {
		return res
	}
}

func performRequest(url string) (bool, time.Duration) {
	t0 := time.Now()
	res, err := http.Get(url)
	t1 := time.Now()
	if err == nil {
		res.Body.Close()
	}

	return err == nil && res.StatusCode == 200, t1.Sub(t0)
}

func sleepUntil(t time.Time, c chan time.Duration) {
	tDone := t.Sub(time.Now())
	c <- -tDone

	for tDone > 0 {
		var sleepDuration time.Duration
		if tDone < 10*time.Millisecond {
			sleepDuration = tDone
		} else {
			sleepDuration = tDone / 2
		}

		time.Sleep(sleepDuration)
		tDone = t.Sub(time.Now())
		c <- -tDone
	}
}

func printStatusHeader() {
	fmt.Println("runtime      lag [ms]       sent      done   waiting        successful   skipped")
}

func printStatus(tStart time.Time, sent int, done int, successful int, lag time.Duration, skipped int) {
	runTime := int(time.Now().Sub(tStart).Seconds())
	nanoLag := float64(lag.Nanoseconds()) / float64(1000000)
	fmt.Printf("\r%6ds  %12.3f   %8d  %8d  %8d  %8d %3.2f%%  %8d", runTime, nanoLag, sent, done, sent-done, successful, 100*float64(successful)/float64(done), skipped)
}<commit_msg>fix width of percent-success in statusline<commit_after>package run

import (
	"bufio"
	"fmt"
	"math/rand"
	"net/http"
	"os"
	"strconv"
	"strings"
	"sync"
	"time"
)

func secsToDuration(delay float64) time.Duration {
	return time.Duration(delay * 1000000000)
}

func calcRampUpPercentage(tStart time.Time, rampUpSecs int) float64 {
	tNow := time.Now()
	rampUpDuration := time.Duration(rampUpSecs) * time.Second
	tRampUpDone := tStart.Add(rampUpDuration)
	rampUpLeft := tRampUpDone.Sub(tNow)

	res := 1 - float64(rampUpLeft)/float64(rampUpDuration)
	if res > 1 {
		return 1
	} else {
		return res
	}
}

func performRequest(url string) (bool, time.Duration) {
	t0 := time.Now()
	res, err := http.Get(url)
	t1 := time.Now()
	if err == nil {
		res.Body.Close()
	}

	return err == nil && res.StatusCode == 200, t1.Sub(t0)
}

func sleepUntil(t time.Time, c chan time.Duration) {
	tDone := t.Sub(time.Now())
	c <- -tDone

	for tDone > 0 {
		var sleepDuration time.Duration
		if tDone < 10*time.Millisecond {
			sleepDuration = tDone
		} else {
			sleepDuration = tDone / 2
		}

		time.Sleep(sleepDuration)
		tDone = t.Sub(time.Now())
		c <- -tDone
	}
}

func printStatusHeader() {
	fmt.Println("runtime      lag [ms]       sent      done   waiting        successful   skipped")
}

func printStatus(tStart time.Time, sent int, done int, successful int, lag time.Duration, skipped int) {
	runTime := int(time.Now().Sub(tStart).Seconds())
	nanoLag := float64(lag.Nanoseconds()) / float64(1000000)
	fmt.Printf("\r%6ds  %12.3f   %8d  %8d  %8d  %8d %6.2f%%  %8d", runTime, nanoLag, sent, done, sent-done, successful, 100*float64(successful)/float64(done), skipped)
}
{'fraction_non_alphanumeric': 0.14739090631675314, 'fraction_numerical': 0.037229173024107415, 'mean_word_length': 3.703012912482066, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '2787041', 'n_tokens_mistral': 1395, 'n_tokens_neox': 1273, 'n_words': 287}