]> git.cryptolib.org Git - avr-crypto-lib.git/blobdiff - hfal-performance.c
performance tools
[avr-crypto-lib.git] / hfal-performance.c
index 391fac8508a0b857bb3f02f76a66119518ec4a9a..e9ec7707a427141ea1d78ec33e840b2183918964 100644 (file)
@@ -60,6 +60,7 @@ void hfal_performance(const hfdesc_t* hd){
        cli_putstr_P(PSTR("\r\n\r\n === "));
        cli_putstr_P(hf.name);
        cli_putstr_P(PSTR(" performance === "
+                         "\r\n    type:             hashfunction"
                          "\r\n    hashsize (bits):    "));
        printvalue(hf.hashsize_b);
        
@@ -69,26 +70,34 @@ void hfal_performance(const hfdesc_t* hd){
        cli_putstr_P(PSTR("\r\n    blocksize (bits):   "));
        printvalue(hf.blocksize_b);
        
-       startTimer(1);
+       startTimer(0);
+       START_TIMER;
        hf.init(&ctx);
+       STOP_TIMER;
        t = stopTimer();
        cli_putstr_P(PSTR("\r\n    init (cycles):      "));
        printvalue(t);
        
-       startTimer(1);
+       startTimer(0);
+       START_TIMER;
        hf.nextBlock(&ctx, data);
+       STOP_TIMER;
        t = stopTimer();
        cli_putstr_P(PSTR("\r\n    nextBlock (cycles): "));
        printvalue(t);
        
-       startTimer(1);
+       startTimer(0);
+       START_TIMER;
        hf.lastBlock(&ctx, data, 0);
+       STOP_TIMER;
        t = stopTimer();
        cli_putstr_P(PSTR("\r\n    lastBlock (cycles): "));
        printvalue(t);
        
-       startTimer(1);
+       startTimer(0);
+       START_TIMER;
        hf.ctx2hash(digest, &ctx);
+       STOP_TIMER;
        t = stopTimer();
        cli_putstr_P(PSTR("\r\n    ctx2hash (cycles):  "));
        printvalue(t);
@@ -99,8 +108,10 @@ void hfal_performance_multiple(const hfdesc_t** hd_list){
        const hfdesc_t* hd;
        for(;;){
                hd = (void*)pgm_read_word(hd_list);
-               if(!hd)
+               if(!hd){
+                       cli_putstr_P(PSTR("\r\n\r\n End of performance figures\r\n"));
                        return;
+               }
                hfal_performance(hd);
                hd_list = (void*)((uint8_t*)hd_list + 2);
        }