使用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

转载于:https://www.cnblogs.com/studyNT/p/7604335.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值