For that, I use 2 scenarios to evaluate the performance. The first scenario writes 2000 (by default) integers into a file. The second scenario reads the saved integers from the file and append them to a buffer. These scenarios exercise I/O, loop and string accumulation to a buffer. Each scenario runs 10 times, discards the best and worst performance then compute the average.
Raspberry Pi model B specs:
CPU: ARM11 700Mhz
RAM: 512MB
OS: Linux
Disk: 8GB class 4
PC specs:
CPU: Intel Core i5 2.6GHz Dual Core with hyper-threading technology
RAM: 16 GB
OS: Windows 7
Disk: 320GB 5400 RPM
Groovy Script to evaluate the performance:
int maxFile = 10
int maxValue = args.length
? args[0].toLong() : 2000
long start
def l = []
// write to file
maxFile.times {
File
f = new File("perf${it}.txt")
start
= System.currentTimeMillis()
maxValue.times
{
f
<< "${it}\n"
}
l
<< System.currentTimeMillis() - start
println
"Write
to file: ${l[it]} ms"
}
println "Write to file avg:${(l.sum() - l.max() - l.min())/(maxFile - 2)} ms"
// read from file
l = []
StringBuilder sb
maxFile.times {
sb
= new StringBuilder(10000)
File
f = new File("perf${it}.txt")
start
= System.currentTimeMillis()
f.eachLine
{
sb.append
it
}
l
<< System.currentTimeMillis() - start
println
"Read
from file: ${l[it]} ms, sb length:${sb.size()}"
}
println "Read from file avg:${(l.sum() - l.max() - l.min())/(maxFile - 2)} ms"
// delete file
maxFile.times {
File
f = new File("perf${it}.txt")
f.delete()
}
RPI Results:
Write to file: 4368 ms
Write to file: 2063 ms
Write to file: 1938 ms
Write to file: 1969 ms
Write to file: 1938 ms
Write to file: 1950 ms
Write to file: 1941 ms
Write to file: 1918 ms
Write to file: 1927 ms
Write to file: 1917 ms
Write to file avg:1955.5 ms
Read from file: 309 ms, sb length:6890
Read from file: 120 ms, sb length:6890
Read from file: 52 ms, sb length:6890
Read from file: 38 ms, sb length:6890
Read from file: 38 ms, sb length:6890
Read from file: 38 ms, sb length:6890
Read from file: 38 ms, sb length:6890
Read from file: 39 ms, sb length:6890
Read from file: 38 ms, sb length:6890
Read from file: 38 ms, sb length:6890
Read from file avg:50.125 ms
PC Results:
Write to file: 1647 ms
Write to file: 1411 ms
Write to file: 1410 ms
Write to file: 1627 ms
Write to file: 1372 ms
Write to file: 1443 ms
Write to file: 1177 ms
Write to file: 2094 ms
Write to file: 1387 ms
Write to file: 1206 ms
Write to file avg:1437.875 ms
Read from file: 16 ms, sb length:6890
Read from file: 14 ms, sb length:6890
Read from file: 8 ms, sb length:6890
Read from file: 18 ms, sb length:6890
Read from file: 11 ms, sb length:6890
Read from file: 11 ms, sb length:6890
Read from file: 12 ms, sb length:6890
Read from file: 7 ms, sb length:6890
Read from file: 6 ms, sb length:6890
Read from file: 2 ms, sb length:6890
Read from file avg:10.625 ms
You may have noticed that the RPI has a slow start and consistent after few iterations while the PC results are varying. In one occurrence, the PC "write" scenario is higher than most of RPI results. On average, the PC "write" scenario is ONLY 1.36 times faster than the RPI. That is really impressive for the RPI. For the "read" scenario, the PC is 4.7 times faster. Finally, by adding the cost on the table, the Raspberry Pi offers a way better cost-performance ratio. By extrapolating these results, it is not a surprise to see new/old companies building computers with several low cost processors such as ARM.
No comments:
Post a Comment