-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstats.go
More file actions
40 lines (34 loc) · 846 Bytes
/
stats.go
File metadata and controls
40 lines (34 loc) · 846 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package tok
import "github.com/GrayCodeAI/tok/internal/filter"
// Stats contains compression statistics.
type Stats struct {
OriginalTokens int
FinalTokens int
TokensSaved int
ReductionPercent float64
Layers map[string]LayerStat
}
// LayerStat contains per-layer statistics.
type LayerStat struct {
TokensSaved int
DurationMs int64
}
func newStats(ps *filter.PipelineStats) Stats {
if ps == nil {
return Stats{}
}
layers := make(map[string]LayerStat, len(ps.LayerStats))
for name, ls := range ps.LayerStats {
layers[name] = LayerStat{
TokensSaved: ls.TokensSaved,
DurationMs: ls.Duration,
}
}
return Stats{
OriginalTokens: ps.OriginalTokens,
FinalTokens: ps.FinalTokens,
TokensSaved: ps.TotalSaved,
ReductionPercent: ps.ReductionPercent,
Layers: layers,
}
}