Skip to content

Commit

Permalink
Rename speed functions
Browse files Browse the repository at this point in the history
  • Loading branch information
guanzhi committed Jun 5, 2024
1 parent b0348be commit 2b09618
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
7 changes: 4 additions & 3 deletions tests/sm2_enctest.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ static int test_sm2_encrypt_fixlen(void)
error_print();
return -1;
}
printf("plaintext len = %zu, ciphertext len = %zu\n", tests[i].plaintext_len, encrypted_len);
if (encrypted_len != encrypted_fixlen) {
error_print();
return -1;
Expand Down Expand Up @@ -282,7 +281,7 @@ static int test_sm2_encrypt(void)
return 1;
}

static int test_sm2_encrypt_ctx_speed(void)
static int speed_sm2_encrypt_ctx(void)
{
SM2_KEY sm2_key;
SM2_ENC_CTX enc_ctx;
Expand Down Expand Up @@ -327,7 +326,9 @@ int main(void)
if (test_sm2_do_encrypt_fixlen() != 1) goto err;
if (test_sm2_encrypt() != 1) goto err;
if (test_sm2_encrypt_fixlen() != 1) goto err;
if (test_sm2_encrypt_ctx_speed() != 1) goto err;
#if ENABLE_TEST_SPEED
if (speed_sm2_encrypt_ctx() != 1) goto err;
#endif
printf("%s all tests passed\n", __FILE__);
return 0;
err:
Expand Down
11 changes: 5 additions & 6 deletions tests/sm2_signtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ static int test_sm2_sign(void)
return 1;
}

static int test_sm2_sign_ctx_speed(void)
static int speed_sm2_sign_ctx(void)
{
SM2_KEY sm2_key;
SM2_SIGN_CTX sign_ctx;
Expand Down Expand Up @@ -205,13 +205,10 @@ static int test_sm2_sign_ctx_speed(void)
sm2_sign_reset(&sign_ctx);
}
end = clock();

seconds = (double)(end - start)/CLOCKS_PER_SEC;

fprintf(stderr, "sm2_sign_ctx speed : 4096 signs time %f seconds, %f signs per second\n", seconds, 4096/seconds);

printf("%s: %f signs per second\n", __FUNCTION__, 4096/seconds);
return 1;

}

static int test_sm2_sign_ctx(void)
Expand Down Expand Up @@ -340,7 +337,9 @@ int main(void)
if (test_sm2_sign() != 1) goto err;
if (test_sm2_sign_ctx() != 1) goto err;
if (test_sm2_sign_reset() != 1) goto err;
if (test_sm2_sign_ctx_speed() != 1) goto err;
#if ENABLE_TEST_SPEED
if (speed_sm2_sign_ctx() != 1) goto err;
#endif
printf("%s all tests passed\n", __FILE__);
return 0;
err:
Expand Down
6 changes: 3 additions & 3 deletions tests/sm3test.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ static int test_sm3(void)
return 1;
}

static int test_sm3_speed(void)
static int speed_sm3(void)
{
SM3_CTX sm3_ctx;
uint8_t blocks[4096];
Expand All @@ -198,7 +198,7 @@ static int test_sm3_speed(void)

seconds = (double)(end - start)/CLOCKS_PER_SEC;

fprintf(stderr, "%s: %f MiB per second\n", __FUNCTION__, 16/seconds);
printf("%s: %f MiB per second\n", __FUNCTION__, 16/seconds);
return 1;
}

Expand All @@ -207,7 +207,7 @@ int main(void)
{
if (test_sm3() != 1) goto err;
#if ENABLE_TEST_SPEED
if (test_sm3_speed() != 1) goto err;
if (speed_sm3() != 1) goto err;
#endif
printf("%s all tests passed\n", __FILE__);
return 0;
Expand Down

0 comments on commit 2b09618

Please sign in to comment.