Giter Site home page Giter Site logo

rsa_cgo's Introduction

关于rsa 签名 使用 cgo (openssl) 和golang 原生库 对比

运行

go get github.com/Bulesxz/rsa_cgo

go test -bench="."

测试环境-1:

硬件概览:
  型号名称:	MacBook Pro
  型号标识符:	MacBookPro13,2
  处理器名称:	Intel Core i5
  处理器速度:	3.1 GHz
  处理器数目:	1
  核总数:	2
  L2 缓存(每个核):	256 KB
  L3 缓存:	4 MB
  内存:	16 GB

os: osx 10.12.3

openssl: OpenSSL 1.1.0f  25 May 2017

golang: go version go1.8.3 darwin/amd64

Result

# 经过测试 发现cgo openssl 的性能是 golang 的 5倍左右 ,5倍!!!!!
BenchmarkGoRsa-4            2000            670399 ns/op
BenchmarkCgoRsa-4          10000            122419 ns/op

测试环境-2:

硬件概览:
  型号名称:	MacBook Pro
  型号标识符:	MacBookPro15,4
  处理器名称:	Intel Core i5
  处理器速度:	1.4 GHz
  处理器数目:	1
  核总数:	4
  L2 缓存(每个核):	256 KB
  L3 缓存:	6 MB
  内存:	16 GB

os: osx 11.0.1

openssl: OpenSSL 1.1.1g  21 Apr 2020

golang: go version go1.15.2 darwin/amd64

Result

BenchmarkGoRsa-8    	    3235	    350276 ns/op
BenchmarkCgoRsa-8   	    8557	    132586 ns/op

场景应用

使用golang rsa 签名的 高并发 程序,比如聚合支付相关(支付宝API)

注意

本人的openssl 安装在 /usr/local/Cellar/[email protected]/1.1.0f/ 不在此目录的可以视情况而改动 makefile

rsa_cgo's People

Contributors

bulesxz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.