Files
OpenCellular/tests/sha_benchmark.c
Randall Spangler 13c0776aab vboot: Remove the remainder of vb1 cryptolib
At this point, all that's left are a few constants in the cryptolib
header files, and they're only used by host-side code.  So move them to
a host-side header file and get rid of cryptolib.

BUG=chromium:611535
BRANCH=none
TEST=make runtests; emerge-kevin coreboot depthcharge

Change-Id: I2235f0e84e13fef313afe54e749b73744b157884
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/400903
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-11-06 02:33:19 +00:00

47 lines
1.1 KiB
C

/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "2sysincludes.h"
#include "2common.h"
#include "2sha.h"
#include "host_common.h"
#include "timer_utils.h"
#define TEST_BUFFER_SIZE 4000000
int main(int argc, char *argv[]) {
int i;
double speed;
uint32_t msecs;
uint8_t *buffer = malloc(TEST_BUFFER_SIZE);
uint8_t digest[VB2_MAX_DIGEST_SIZE];
ClockTimerState ct;
/* Iterate through all the hash functions. */
for(i = VB2_HASH_SHA1; i < VB2_HASH_ALG_COUNT; i++) {
StartTimer(&ct);
vb2_digest_buffer(buffer, TEST_BUFFER_SIZE, i,
digest, sizeof(digest));
StopTimer(&ct);
msecs = GetDurationMsecs(&ct);
speed = ((TEST_BUFFER_SIZE / 10e6)
/ (msecs / 10e3)); /* Mbytes/sec */
fprintf(stderr,
"# %s Time taken = %u ms, Speed = %f Mbytes/sec\n",
vb2_get_hash_algorithm_name(i), msecs, speed);
fprintf(stdout, "mbytes_per_sec_%s:%f\n",
vb2_get_hash_algorithm_name(i), speed);
}
free(buffer);
return 0;
}