[test] Add speed tests for digest algorithms

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2012-09-26 14:54:02 +01:00
parent 09cc63fc8b
commit 681a219caa
5 changed files with 54 additions and 0 deletions

View File

@@ -75,9 +75,11 @@ static struct digest_test_fragments sha1_test_fragments[] = {
static void sha1_test_exec ( void ) {
struct digest_algorithm *digest = &sha1_algorithm;
struct sha1_test_vector *test;
unsigned long cost;
unsigned int i;
unsigned int j;
/* Correctness test */
for ( i = 0 ; i < ( sizeof ( sha1_test_vectors ) /
sizeof ( sha1_test_vectors[0] ) ) ; i++ ) {
test = &sha1_test_vectors[i];
@@ -90,6 +92,10 @@ static void sha1_test_exec ( void ) {
test->data, test->len, test->digest );
}
}
/* Speed test */
cost = digest_cost ( digest );
DBG ( "SHA1 required %ld cycles per byte\n", cost );
}
/** SHA-1 self-test */