<commit_before>package queue

import "time"
import "encoding/binary"

type Metrics interface {
	Executor() string
	BeginTime() time.Time
	FinishTime() time.Time

	Calculate(interface{})

	ElapsedTime() time.Duration
	MemoryUsage() int
}

func NewMetrics(executor string) Metrics { // {{{
	m := metricsPoolGet()
	m.executor = executor
	m.beginTime = time.Now()
	return m
} // }}}

type metrics struct {
	executor    string
	beginTime   time.Time
	finishTime  time.Time
	memoryUsage int
}

func (this *metrics) Reset() { // {{{
	this.executor = ""
	this.beginTime = time.Time{}
	this.finishTime = time.Time{}
	this.memoryUsage = 0
} // }}}

func (this *metrics) Release() { // {{{
	metricsPoolPut(this)
} // }}}

func (this *metrics) Executor() string { // {{{
	return this.executor
} // }}}

func (this *metrics) BeginTime() time.Time { // {{{
	return this.beginTime
} // }}}

func (this *metrics) FinishTime() time.Time { // {{{
	return this.finishTime
} // }}}

func (this *metrics) Calculate(v interface{}) { // {{{
	this.finishTime = time.Now()
	this.memoryUsage = binary.Size(v)
} // }}}

func (this *metrics) ElapsedTime() time.Duration { // {{{
	return this.finishTime.Sub(this.beginTime)
} // }}}

func (this *metrics) MemoryUsage() int { // {{{
	return this.memoryUsage
} // }}}<commit_msg>Use unsafe.Sizeof to get size of struct<commit_after>package queue

import "time"
import "unsafe"

type Metrics interface {
	Executor() string
	BeginTime() time.Time
	FinishTime() time.Time

	Calculate(interface{})

	ElapsedTime() time.Duration
	MemoryUsage() uintptr
}

func NewMetrics(executor string) Metrics { // {{{
	m := metricsPoolGet()
	m.executor = executor
	m.beginTime = time.Now()
	return m
} // }}}

type metrics struct {
	executor    string
	beginTime   time.Time
	finishTime  time.Time
	memoryUsage uintptr
}

func (this *metrics) Reset() { // {{{
	this.executor = ""
	this.beginTime = time.Time{}
	this.finishTime = time.Time{}
	this.memoryUsage = 0
} // }}}

func (this *metrics) Release() { // {{{
	metricsPoolPut(this)
} // }}}

func (this *metrics) Executor() string { // {{{
	return this.executor
} // }}}

func (this *metrics) BeginTime() time.Time { // {{{
	return this.beginTime
} // }}}

func (this *metrics) FinishTime() time.Time { // {{{
	return this.finishTime
} // }}}

func (this *metrics) Calculate(v interface{}) { // {{{
	this.finishTime = time.Now()
	this.memoryUsage = unsafe.Sizeof(v)
} // }}}

func (this *metrics) ElapsedTime() time.Duration { // {{{
	return this.finishTime.Sub(this.beginTime)
} // }}}

func (this *metrics) MemoryUsage() uintptr { // {{{
	return this.memoryUsage
} // }}}
{'fraction_non_alphanumeric': 0.17814998096688237, 'fraction_numerical': 0.0007613247049866769, 'mean_word_length': 3.618629173989455, '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': '4354621', 'n_tokens_mistral': 921, 'n_tokens_neox': 904, 'n_words': 212}