tools
tools copied to clipboard
Benchmark for decoder performance (privkey) #454
pemread.c/pemread gets renamed to pkeyread.c/pkeyread The tool can newly benchmak RSA, DSA, DH, DHX, EC, XKEY.
To run benchmark for all keys and both formats (PEM, DER) using four threads execute pkeyread command as follows:
./pkeyread -k all -f all -t 4
The output will look like this:
lifty$ ./pkeyread -k all -f all -t 4
[dh pem] 317963.170000
[dh der] 323924.870000
[dhx pem] 76381.500000
[dhx der] 81370.580000
[dsa pem] 84088.790000
[dsa der] 84630.180000
[ec pem] 24644.910000
[ec der] 77426.390000
[rsa pem] 41520.410000
[rsa der] 65746.920000
[xkey pem] 17786.360000
[xkey der] 20157.880000
Change also adds genkey.sh which generates private keys
for testing. The script is called by Makefile as regen_key_samples
target. Makefile generates the key samples into keys.h.
The keys.h file is also committed to minimize a builttime
dependency on genkey.sh script.
To add a new key one should update genkey.sh script,
run make regen_key_samples and commit new version
of keys.h file.
rebased on current.
New revision is rebased on current. the list of changes is as follows
- introduced
report_result()function to remove code duplication (pointed out by @mattcaswell) - fixed indentation at
fprintf()functions (by @mattcaswell ) - fixed typo in
genkeys.sh - updated README
opened issues:
- Shall I add license header to keys.h which is generated by genkeys.sh
- Shall I remove calls to X509_PUBKEY_*() found in do_derread() function
the new version will arrive shortly, resolved items:
- add a copyright header to
keys.h - remove calls to
X509_PUBKEY_*()functions
item which needs further clarification:
- remove duplicate code.
There seems to be an extra commit in this PR from #182. I suspect #182 was merged to the wrong repo - but your PR picked it up before it later got wiped by the next mirror.
Anyway - no big deal.
Conflicts with PR which added rwlock tests got resolved. Please check changes to Makefile and Readme file. thanks.
Please rebase and drop the merge commits.
sorry about poor git driving, the merge commits should be gone now.
and now with fix for glitch spotted by matt
the pull request will be updated shortly. The list of changes is as follows:
- the benchmark for DER uses
d2i_PrivateKey_ex()now. it required changes togenkey.shso it also generates table ofEVP_PKEY_*constants with keys supported by test.keys.hgot regenrated. - I also made two tweaks to report results, the diff chunk for this bellow
@@ -168,13 +157,14 @@ static int format_name_to_id(const char *format_name)
return i;
}
-double get_avcalltime(void)
+static double get_avcalltime(void)
{
int i;
OSSL_TIME t;
double avcalltime;
- for (i = 1; i < threadcount; i++)
+ memset(&t, 0, sizeof(t));
+ for (i = 0; i < threadcount; i++)
t = ossl_time_add(t, times[i]);
avcalltime = (double)ossl_time2ticks(t) / (double)NUM_CALLS_PER_TEST;
@@ -183,7 +173,7 @@ double get_avcalltime(void)
return avcalltime;
}
-void report_result(int key_id, int format_id, int verbose)
+static void report_result(int key_id, int format_id, int verbose)
{
if (err) {
fprintf(stderr, "Error during test of %s in %s format\n",
@@ -192,10 +182,10 @@ void report_result(int key_id, int format_id, int verbose)
}
if (verbose)
- printf("Average time per %s(%s) calls: %lfus\n",
+ printf("Average time per %s(%s) call: %lfus\n",
format_names[format_id], sample_names[key_id], get_avcalltime());
else
- printf("[%s %s] %lf\n", sample_names[key_id],
+ printf("[%s %s] %lfus\n", sample_names[key_id],
format_names[format_id], get_avcalltime());
}
Why it was necessary to change the key data? IMO d2i_PrivateKey_ex() should be able to decode the original data.
Why it was necessary to change the key data? IMO d2i_PrivateKey_ex() should be able to decode the original data.
keys.h now contains array with EVP_PKEY_ constant. I use this array later in newly introduced function sample_id_to_evp(). I could add that array to keys.h by hand, but I decided to give the genkeys.h script a try.
README got updated.
rebased to master.
approval holds
My approval holds too. Merging.
Actually @mattcaswell could you please also reconfirm?
Merged. Thank you.