init: v1.0.0

This commit is contained in:
yaole
2026-05-27 23:03:00 +08:00
commit 8d97f750eb
466 changed files with 80067 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
package drng_test
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"xdx.jelly/xgcl/grand/drng"
)
// 0.03GBps, 主要是internal.Outlen太小
func TestSM3RngSpeed(t *testing.T) {
data := make([]byte, 10*1024*1024)
start := time.Now()
times := 10
for i := 0; i < times; i++ {
_, err := drng.SM3Rng.Read(data)
assert.Nil(t, err)
}
end := time.Now()
elapsed := end.Sub(start)
t.Logf("Generate Random speed: %.2f MBps\n", float64(times*len(data))/float64(1024*1024)/elapsed.Seconds())
}
func TestSM4RngSpeed(t *testing.T) {
data := make([]byte, 10*1024*1024)
start := time.Now()
times := 10
for i := 0; i < times; i++ {
_, err := drng.SM4Rng.Read(data)
assert.Nil(t, err)
}
end := time.Now()
elapsed := end.Sub(start)
t.Logf("Generate Random speed: %.2f MBps\n", float64(times*len(data))/float64(1024*1024)/elapsed.Seconds())
}