]> git.cryptolib.org Git - avr-crypto-lib.git/blob - host/performance2wiki.rb
9d46dd3380887b3cb12f76fce58b710c55c827bc
[avr-crypto-lib.git] / host / performance2wiki.rb
1 #!/usr/bin/ruby
2 # performnce to wiki
3
4 =begin
5     This file is part of the AVR-Crypto-Lib.
6     Copyright (C) 2009  Daniel Otte (daniel.otte@rub.de)
7
8     This program is free software: you can redistribute it and/or modify
9     it under the terms of the GNU General Public License as published by
10     the Free Software Foundation, either version 3 of the License, or
11     (at your option) any later version.
12
13     This program is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU General Public License for more details.
17
18     You should have received a copy of the GNU General Public License
19     along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 =end
21
22 =begin
23  === Twister-256 performance === 
24     type:                     hash
25     hashsize (bits):           256
26     ctxsize (bytes):            80
27     blocksize (bits):          512
28     init (cycles):             425
29     nextBlock (cycles):      36535
30     lastBlock (cycles):       8071
31     ctx2hash (cycles):       19431
32 =end
33
34 def process_hashfunction(fin, name)
35   lb = fin.readline()
36   m = lb.match(/hashsize \(bits\):[\s]*([\d]*)/)
37   if(!m)
38         printf("unexpected string %s\n", lb)
39   end
40   hashsize = m[1].to_i()
41   lb = fin.readline()
42   m = lb.match(/ctxsize \(bytes\):[\s]*([\d]*)/)
43   ctxsize = m[1].to_i()
44   lb = fin.readline()
45   m = lb.match(/blocksize \(bits\):[\s]*([\d]*)/)
46   blocksize = m[1].to_i()
47   lb = fin.readline()
48   m = lb.match(/init \(cycles\):[\s]*([\d]*)/)
49   inittime = m[1].to_i()
50   lb = fin.readline()
51   m = lb.match(/nextBlock \(cycles\):[\s]*([\d]*)/)
52   nextblocktime = m[1].to_i()  
53   lb = fin.readline()
54   m = lb.match(/lastBlock \(cycles\):[\s]*([\d]*)/)
55   lastblocktime = m[1].to_i()
56   lb = fin.readline()
57   m = lb.match(/ctx2hash \(cycles\):[\s]*([\d]*)/)
58   convtime = m[1].to_i()
59   
60   printf("| %s || C || C || || %4d || %4d || %4d || %6d || %6d || %6.2f || %6d || || || \n|-\n" , 
61     name, ctxsize, hashsize, blocksize, inittime, nextblocktime, nextblocktime.to_f/blocksize*8, lastblocktime+convtime)
62 end
63
64
65 $handlers = Hash.new
66 $handlers.default = 0
67 $handlers["hashfunction"] = 1 #process_hashfunction
68
69 def process_file(fname)
70   fin = File.open(fname, "r")
71   begin
72     begin
73           if fin.eof()
74                 return
75           end
76       lb = fin.readline()
77     end while !m=lb.match(/=== (.*) performance ===/)
78     name = m[1];
79     lb = fin.readline()
80     m = lb.match(/type:[\s]*([\w]*)/)
81     type = m[1]
82     if $handlers[type] != 0
83     #  handlers[type](fin, name)
84       process_hashfunction(fin, name)
85     else
86       printf("ERROR: unsupported type: %s !\n", type)
87     end 
88   end while(true)
89   fin.close()
90 end
91
92 for i in (0..ARGV.size-1)
93   process_file(ARGV[i])
94 end
95
96
97
98
99
100
101