Saturday, October 23, 2010

How much faster is your iPhone's CPU compared with your computer?

Had this strange idea while working in SSE Labs office today.. it's by no means accurate or representative of anything other than OpenSSL performance - it doesn't even use multiple cores - but it gives you some idea of the magnitudes we're talking about.

The test is done by the command
$ openssl speed rsa

It's very easy. Every UNIX computer with OpenSSL can do it.

iPhone 3GS:
Martin-Kous-iPhone:~ root# openssl speed rsa
To get the most accurate results, try to run this
program when this computer is idle.
Doing 512 bit private rsa's for 10s: 1997 512 bit private RSA's in 9.78s
Doing 512 bit public rsa's for 10s: 22561 512 bit public RSA's in 9.80s
Doing 1024 bit private rsa's for 10s: 378 1024 bit private RSA's in 9.81s
Doing 1024 bit public rsa's for 10s: 7353 1024 bit public RSA's in 9.54s
Doing 2048 bit private rsa's for 10s: 62 2048 bit private RSA's in 9.83s
Doing 2048 bit public rsa's for 10s: 2200 2048 bit public RSA's in 9.81s
Doing 4096 bit private rsa's for 10s: 10 4096 bit private RSA's in 10.68s
Doing 4096 bit public rsa's for 10s: 617 4096 bit public RSA's in 9.75s
OpenSSL 0.9.8k 25 Mar 2009
built on: date not available
options:bn(64,32) md2(int) rc4(ptr,char) des(idx,cisc,16,long) aes(partial) idea(int) blowfish(ptr)
compiler: arm-apple-darwin9-gcc -fPIC -fno-common -DOPENSSL_PIC -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -D__DARWIN_UNIX03 -O3 -fomit-frame-pointer -fno-common
available timing options: TIMEB USE_TOD HZ=100 [sysconf value]
timing function used: getrusage
sign verify sign/s verify/s
rsa 512 bits 0.004897s 0.000434s 204.2 2302.1
rsa 1024 bits 0.025952s 0.001297s 38.5 770.8
rsa 2048 bits 0.158548s 0.004459s 6.3 224.3
rsa 4096 bits 1.068000s 0.015802s 0.9 63.3


2007 MacBook Pro:
Martin-Kous-MacBook-Pro:Downloads martinkou$ openssl speed rsa
Doing 512 bit private rsa's for 10s: 25711 512 bit private RSA's in 9.92s
Doing 512 bit public rsa's for 10s: 316964 512 bit public RSA's in 9.93s
Doing 1024 bit private rsa's for 10s: 5190 1024 bit private RSA's in 9.90s
Doing 1024 bit public rsa's for 10s: 93072 1024 bit public RSA's in 8.72s
Doing 2048 bit private rsa's for 10s: 833 2048 bit private RSA's in 9.58s
Doing 2048 bit public rsa's for 10s: 30686 2048 bit public RSA's in 9.75s
Doing 4096 bit private rsa's for 10s: 133 4096 bit private RSA's in 9.88s
Doing 4096 bit public rsa's for 10s: 9285 4096 bit public RSA's in 9.91s
OpenSSL 1.0.0a 1 Jun 2010
built on: Sat Oct 2 20:39:58 PDT 2010
options:bn(64,64) rc4(ptr,char) des(idx,cisc,16,int) aes(partial) idea(int) blowfish(idx)
compiler: /usr/bin/gcc-4.2 -fPIC -fno-common -DOPENSSL_PIC -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -arch x86_64 -O3 -DL_ENDIAN -DMD32_REG_T=int -Wall
sign verify sign/s verify/s
rsa 512 bits 0.000386s 0.000031s 2591.8 31919.8
rsa 1024 bits 0.001908s 0.000094s 524.2 10673.4
rsa 2048 bits 0.011501s 0.000318s 87.0 3147.3
rsa 4096 bits 0.074286s 0.001067s 13.5 936.9


Xeon X3450 Server:
martinkou@hydrogen:~$ openssl speed rsa
Doing 512 bit private rsa's for 10s: 102939 512 bit private RSA's in 10.00s
Doing 512 bit public rsa's for 10s: 1143301 512 bit public RSA's in 10.00s
Doing 1024 bit private rsa's for 10s: 21075 1024 bit private RSA's in 10.00s
Doing 1024 bit public rsa's for 10s: 398744 1024 bit public RSA's in 10.00s
Doing 2048 bit private rsa's for 10s: 3418 2048 bit private RSA's in 10.01s
Doing 2048 bit public rsa's for 10s: 115004 2048 bit public RSA's in 10.00s
Doing 4096 bit private rsa's for 10s: 487 4096 bit private RSA's in 10.02s
Doing 4096 bit public rsa's for 10s: 30813 4096 bit public RSA's in 10.00s
OpenSSL 0.9.8k 25 Mar 2009
built on: Thu Aug 12 13:29:53 UTC 2010
options:bn(64,64) md2(int) rc4(ptr,char) des(idx,cisc,16,int) aes(partial) blowfish(ptr2)
compiler: cc -fPIC -DOPENSSL_PIC -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -m64 -DL_ENDIAN -DTERMIO -O3 -Wa,--noexecstack -g -Wall -DMD32_REG_T=int -DOPENSSL_BN_ASM_MONT -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM
available timing options: TIMES TIMEB HZ=100 [sysconf value]
timing function used: times
sign verify sign/s verify/s
rsa 512 bits 0.000097s 0.000009s 10293.9 114330.1
rsa 1024 bits 0.000474s 0.000025s 2107.5 39874.4
rsa 2048 bits 0.002929s 0.000087s 341.5 11500.4
rsa 4096 bits 0.020575s 0.000325s 48.6 3081.3


So the average iPhone is roughly 10 to 40x slower than your desktop computer, if we don't include the 1 or 11 other CPU cores in your desktop. If that is included as well.. your desktop computer is easily 100x faster than your iPhone.

3 comments:

H. Mijail said...

Hi there. I just thought about the same test and posted it on my blog ( http://hmijailblog.blogspot.com/2011/02/openssl-speed-on-iphone-4.html )

As I also note there, OpenSSL has different optimizations for different architectures; if I remember correctly, when I checked the sources there were implementations using vector extensions (MMX, SSE and such) and downright assembler for Intel processors.

So to be able to compare, the question should include how is the ARM implementation optimized? That already made comparisons between PowerPC and Intel processors difficult!

Anonymous said...

Great аrticle, totаlly ωhat І waѕ looking fоr.


Feel frее to surf to my homepаge; disque dur SSD

Anonymous said...

Everything is very open with a really clear explanation of the issues.
It was definitely informative. Your site is very useful.

Thanks for sharing!

Feel free to surf to my web-site - tarot de Marseille