<commit_before>package nw_bandwidth

import (
	"github.com/watermint/bwlimit"
	"github.com/watermint/toolbox/infra/control/app_root"
	"go.uber.org/zap"
	"io"
)

var (
	throttle = bwlimit.NewBwlimit(0, false)
)

// Set bandwidth limit in Kilo Bytes per second.
func SetBandwidth(kps int) {
	app_root.Log().Debug("Bandwidth limit", zap.Int("kbs", kps))
	throttle.SetRateLimit(kps * 1024)
}

func WrapReader(r io.Reader) io.Reader {
	return throttle.Reader(r)
}

func WrapWriter(w io.Writer) io.Writer {
	return throttle.Writer(w)
}<commit_msg>#219 : skip bandwidth limit when no<commit_after>package nw_bandwidth

import (
	"github.com/watermint/bwlimit"
	"github.com/watermint/toolbox/infra/control/app_root"
	"go.uber.org/zap"
	"io"
)

var (
	throttle     = bwlimit.NewBwlimit(0, false)
	currentLimit = 0
)

// Set bandwidth limit in Kilo Bytes per second.
func SetBandwidth(kps int) {
	app_root.Log().Debug("Bandwidth limit", zap.Int("kbs", kps))
	throttle.SetRateLimit(kps * 1024)
	currentLimit = kps
}

func WrapReader(r io.Reader) io.Reader {
	if currentLimit == 0 {
		return r
	}
	return throttle.Reader(r)
}

func WrapWriter(w io.Writer) io.Writer {
	if currentLimit == 0 {
		return w
	}
	return throttle.Writer(w)
}
{'fraction_non_alphanumeric': 0.1342062193126023, 'fraction_numerical': 0.01309328968903437, 'mean_word_length': 4.387665198237886, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2219675', 'n_tokens_mistral': 516, 'n_tokens_neox': 488, 'n_words': 99}