Fix check for whether a dependency was built + improved mpw-bench output.
This commit is contained in:
parent
794d064a99
commit
18f8ebb9dc
@ -85,8 +85,7 @@ depend() {
|
||||
|
||||
echo
|
||||
echo "Checking dependency $1..."
|
||||
objects=( "lib/$1"/*.o )
|
||||
[[ -e $objects ]] && return
|
||||
[[ -e "lib/$1/.built" ]] && return
|
||||
|
||||
pushd "lib/$1"
|
||||
files=( * )
|
||||
@ -113,6 +112,7 @@ depend() {
|
||||
echo "Building dependency $1..."
|
||||
if [[ -e Makefile ]]; then
|
||||
make
|
||||
date > .built
|
||||
else
|
||||
echo >&2 "error: Don't know how to build: $1"
|
||||
exit 1
|
||||
@ -125,6 +125,7 @@ depend() {
|
||||
mpw() {
|
||||
depend scrypt
|
||||
|
||||
echo
|
||||
echo "Building target: $target..."
|
||||
CFLAGS=(
|
||||
# include paths
|
||||
@ -155,6 +156,7 @@ mpw-bench() {
|
||||
depend scrypt
|
||||
depend bcrypt
|
||||
|
||||
echo
|
||||
echo "Building target: $target..."
|
||||
CFLAGS=(
|
||||
# include paths
|
||||
@ -198,6 +200,5 @@ cc() {
|
||||
}
|
||||
|
||||
for target in "${targets[@]}"; do
|
||||
echo
|
||||
"$target" "$@"
|
||||
done
|
||||
|
@ -110,7 +110,8 @@ int main(int argc, char *const argv[]) {
|
||||
}
|
||||
memset(sitePasswordSeed, 0, sizeof(sitePasswordSeed));
|
||||
|
||||
fprintf( stderr, "\riteration %d / %d..", i, iterations );
|
||||
if (i % 1 == 0)
|
||||
fprintf( stderr, "\rmpw: iteration %d / %d..", i, iterations );
|
||||
}
|
||||
|
||||
// Output timing results.
|
||||
@ -122,7 +123,8 @@ int main(int argc, char *const argv[]) {
|
||||
long long secs = (endTime.tv_sec - startTime.tv_sec);
|
||||
long long usecs = (endTime.tv_usec - startTime.tv_usec);
|
||||
double elapsed = secs + usecs / 1000000.0;
|
||||
fprintf( stdout, "Master Password: %d iterations in %llds %lldµs -> %.2f/s\n", iterations, secs, usecs, iterations / elapsed );
|
||||
double mpwSpeed = iterations / elapsed;
|
||||
fprintf( stdout, " done. %d iterations in %llds %lldµs -> %.2f/s\n", iterations, secs, usecs, mpwSpeed );
|
||||
|
||||
// Start SHA-256
|
||||
if (gettimeofday(&startTime, NULL) != 0) {
|
||||
@ -134,7 +136,9 @@ int main(int argc, char *const argv[]) {
|
||||
uint8_t hash[32];
|
||||
for (int i = 0; i < iterations; ++i) {
|
||||
SHA256_Buf(masterPassword, strlen(masterPassword), hash);
|
||||
fprintf( stderr, "\riteration %d / %d..", i, iterations );
|
||||
|
||||
if (i % 1000 == 0)
|
||||
fprintf( stderr, "\rsha256: iteration %d / %d..", i, iterations );
|
||||
}
|
||||
|
||||
// Output timing results.
|
||||
@ -145,7 +149,8 @@ int main(int argc, char *const argv[]) {
|
||||
secs = (endTime.tv_sec - startTime.tv_sec);
|
||||
usecs = (endTime.tv_usec - startTime.tv_usec);
|
||||
elapsed = secs + usecs / 1000000.0;
|
||||
fprintf( stdout, "SHA-256: %d iterations in %llds %lldµs -> %.2f/s\n", iterations, secs, usecs, iterations / elapsed );
|
||||
double sha256Speed = iterations / elapsed;
|
||||
fprintf( stdout, " done. %d iterations in %llds %lldµs -> %.2f/s\n", iterations, secs, usecs, sha256Speed );
|
||||
|
||||
// Start BCrypt
|
||||
if (gettimeofday(&startTime, NULL) != 0) {
|
||||
@ -157,7 +162,9 @@ int main(int argc, char *const argv[]) {
|
||||
iterations = 600;
|
||||
for (int i = 0; i < iterations; ++i) {
|
||||
crypt(masterPassword, crypt_gensalt("$2b$", bcrypt_cost, userName, strlen(userName)));
|
||||
fprintf( stderr, "\riteration %d / %d..", i, iterations );
|
||||
|
||||
if (i % 10 == 0)
|
||||
fprintf( stderr, "\rbcrypt (cost %d): iteration %d / %d..", bcrypt_cost, i, iterations );
|
||||
}
|
||||
|
||||
// Output timing results.
|
||||
@ -168,7 +175,13 @@ int main(int argc, char *const argv[]) {
|
||||
secs = (endTime.tv_sec - startTime.tv_sec);
|
||||
usecs = (endTime.tv_usec - startTime.tv_usec);
|
||||
elapsed = secs + usecs / 1000000.0;
|
||||
fprintf( stdout, "BCrypt (cost %d): %d iterations in %llds %lldµs -> %.2f/s\n", bcrypt_cost, iterations, secs, usecs, iterations / elapsed );
|
||||
double bcrypt9Speed = iterations / elapsed;
|
||||
fprintf( stdout, " done. %d iterations in %llds %lldµs -> %.2f/s\n", iterations, secs, usecs, bcrypt9Speed );
|
||||
|
||||
// Summarize.
|
||||
fprintf( stdout, "\n== SUMMARY ==\nOn this machine,\n" );
|
||||
fprintf( stdout, "mpw is %f times slower than sha256\n", sha256Speed / mpwSpeed );
|
||||
fprintf( stdout, "mpw is %f times slower than bcrypt (cost 9)\n", bcrypt9Speed / mpwSpeed );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user