forked from Consensys/gnark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstats_test.go
52 lines (43 loc) · 1.27 KB
/
stats_test.go
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
41
42
43
44
45
46
47
48
49
50
51
52
package stats
import (
"fmt"
"testing"
"github.com/consensys/gnark/backend"
"github.com/stretchr/testify/require"
)
func TestCircuitStatistics(t *testing.T) {
const refPath = "latest_stats.csv"
assert := require.New(t)
// load reference
reference := NewGlobalStats()
assert.NoError(reference.Load(refPath))
snippets := GetSnippets()
// for each circuit, on each curve, on each backend
// compare with reference stats
for name, c := range snippets {
// check that we have it.
ref, ok := reference.Stats[name]
if !ok {
t.Log("warning: no stats for circuit", name)
return
}
for _, curve := range c.Curves {
for _, b := range backend.Implemented() {
curve := curve
backendID := b
name := name
// copy the circuit now in case assert calls t.Parallel()
circuit := c.Circuit
t.Run(fmt.Sprintf("%s/%s/%s", name, curve.String(), backendID.String()), func(t *testing.T) {
assert := require.New(t)
rs := ref[backendID][curve]
s, err := NewSnippetStats(curve, backendID, circuit)
assert.NoError(err, "building stats for circuit "+name)
if s != rs {
assert.Failf("unexpected stats count", "expected %s (reference), got %s. %s - %s - %s", rs, s, name, backendID.String(), curve.String())
}
})
}
}
}
}