使用JWT的RSA256加密做為用戶認證, 測試性能


http://www.giantflyingsaucer.com/blog/?p=5994


使用JWT的token認證,防止別人知道了接口后,隨意調用,但是發現
stepping : 4 microcode : 0x428 cpu MHz : 2600.062 cache size : 20480 KB physical id : 0 siblings : 1 core id : 0 cpu cores : 1 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl pni ssse3 cx16 sse4_1 sse4_2 popcnt aes hypervisor lahf_lm bogomips : 5200.12 clflush size : 64 cache_alignment : 64 address sizes : 46 bits physical, 48 bits virtual

使用 go test -test.bench=".*" -v 命令測試,發現加密的挺耗時間的
goos: linux goarch: amd64 pkg: github.com/KerryJava/goserver Benchmark_TimeConsumingOrm 5000 265224 ns/op Benchmark_TimeConsumingOrm 5000 248941 ns/op Benchmark_TimeConsumingOrm 10000 245728 ns/op Benchmark_TimeConsumingOrm 5000 268391 ns/op Benchmark_TimeConsumingOrm 5000 247001 ns/op Benchmark_TimeConsumingFunctionRawQuery 10000 215219 ns/op Benchmark_TimeConsumingFunctionRawQuery 10000 213085 ns/op Benchmark_TimeConsumingFunctionRawQuery 10000 210200 ns/op Benchmark_TimeConsumingFunctionRawQuery 10000 209737 ns/op Benchmark_TimeConsumingFunctionRawQuery 10000 209695 ns/op Benchmark_TimeConsumingFunctionRawQueryPrepare 20000 65998 ns/op Benchmark_TimeConsumingFunctionRawQueryPrepare 20000 66214 ns/op Benchmark_TimeConsumingFunctionRawQueryPrepare 20000 67460 ns/op Benchmark_TimeConsumingFunctionRawQueryPrepare 20000 67988 ns/op Benchmark_TimeConsumingFunctionRawQueryPrepare 20000 67424 ns/op Benchmark_JWTRSA256Sign 300 4128990 ns/op Benchmark_JWTRSA256Sign 300 4119935 ns/op Benchmark_JWTRSA256Sign 300 4175446 ns/op Benchmark_JWTRSA256Sign 300 4121553 ns/op Benchmark_JWTRSA256Sign 300 4137870 ns/op Benchmark_JWTRSA256Decode 10000 139202 ns/op Benchmark_JWTRSA256Decode 10000 138939 ns/op Benchmark_JWTRSA256Decode 10000 139415 ns/op Benchmark_JWTRSA256Decode 10000 139179 ns/op Benchmark_JWTRSA256Decode 10000 137128 ns/op PASS ok github.com/KerryJava/goserver 43.983s


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM