39 lines
871 B
Go
39 lines
871 B
Go
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())
|
|
}
|