📄 bench.c
字号:
sticks = GetTickCount();
nbytes = 0;
running = TRUE;
while (running) {
for (i = k = 0; i < 1600; i += 160) {
if ((GetTickCount() - sticks) > BenchInterval) {
running = FALSE;
break;
}
lpc_analyze(raw + i, &lp);
nbytes += 160;
memcpy(out + k, &lp, sizeof lp);
k += sizeof lp;
}
}
Speedo(IDC_BE_C_LPC);
sticks = GetTickCount();
nbytes = 0;
running = TRUE;
while (running) {
for (i = 0; i < 10; i++) {
if ((GetTickCount() - sticks) > BenchInterval) {
running = FALSE;
break;
}
lpc_synthesize(out + 400,
(lpcparams_t *) (out + (i * sizeof lp)),
&state);
nbytes += 160;
}
}
Speedo(IDC_BE_D_LPC);
}
// LPC-10
{
int i, j;
sticks = GetTickCount();
nbytes = 0;
running = TRUE;
while (running) {
if ((GetTickCount() - sticks) > BenchInterval) {
running = FALSE;
break;
}
j = lpc10encode(raw, out, 1440);
nbytes += 1440;
}
Speedo(IDC_BE_C_LPC10);
sticks = GetTickCount();
nbytes = 0;
running = TRUE;
while (running) {
if ((GetTickCount() - sticks) > BenchInterval) {
running = FALSE;
break;
}
i = lpc10decode(out, out + 100, j);
nbytes += i;
}
Speedo(IDC_BE_D_LPC10);
}
#ifdef CRYPTO
// Encryption benchmarks
// AES
{
aes_ctx ectx, dctx;
sticks = GetTickCount();
nbytes = 0;
running = TRUE;
ectx.n_rnd = ectx.n_blk = 0;
aes_enc_key(raw, 16, &ectx);
while (running) {
if ((GetTickCount() - sticks) > BenchInterval) {
running = FALSE;
break;
}
AES_cbc_encrypt((unsigned char *) raw,
(unsigned char *) raw,
1600, &ectx);
nbytes += 1600;
}
Speedo(IDC_BE_E_AES);
sticks = GetTickCount();
nbytes = 0;
running = TRUE;
dctx.n_rnd = dctx.n_blk = 0;
aes_dec_key(raw, 16, &dctx);
while (running) {
if ((GetTickCount() - sticks) > BenchInterval) {
running = FALSE;
break;
}
AES_cbc_decrypt((unsigned char *) raw,
(unsigned char *) raw,
1600, &dctx);
nbytes += 1600;
}
Speedo(IDC_BE_D_AES);
}
// DES (Speak Freely protocol)
{
int i;
char tbuf[8], bbuf[8];
sticks = GetTickCount();
nbytes = 0;
running = TRUE;
setkey(raw);
while (running) {
if ((GetTickCount() - sticks) > BenchInterval) {
running = FALSE;
break;
}
for (i = 0; i < 1600; i += 8) {
if (i > 0) {
int j;
for (j = 0; j < 8; j++) {
raw[(i + j)] ^= raw[(i + j) - 8];
}
}
endes(raw + i);
}
nbytes += 1600;
}
Speedo(IDC_BE_E_DES);
sticks = GetTickCount();
nbytes = 0;
running = TRUE;
while (running) {
if ((GetTickCount() - sticks) > BenchInterval) {
running = FALSE;
break;
}
for (i = 0; i < 1600; i += 8) {
memcpy(tbuf, raw + i, 8);
dedes(raw + i);
/* Reverse cipher block chaining. */
if (i > 0) {
int j;
for (j = 0; j < 8; j++) {
raw[(i + j)] ^= bbuf[j];
}
}
memcpy(bbuf, tbuf, 8);
}
nbytes += 1600;
}
Speedo(IDC_BE_D_DES);
}
// DES (VAT/RTP protocol)
{
des_key_schedule sched;
des_cblock ivec;
sticks = GetTickCount();
nbytes = 0;
running = TRUE;
des_set_key((des_cblock *) raw, sched);
while (running) {
if ((GetTickCount() - sticks) > BenchInterval) {
running = FALSE;
break;
}
memset(ivec, 0, 8);
des_ncbc_encrypt((des_cblock *) raw,
(des_cblock *) raw, 1600, sched,
(des_cblock *) ivec, DES_ENCRYPT);
nbytes += 1600;
}
Speedo(IDC_BE_E_DES_RTP);
sticks = GetTickCount();
nbytes = 0;
running = TRUE;
while (running) {
if ((GetTickCount() - sticks) > BenchInterval) {
running = FALSE;
break;
}
memset(ivec, 0, 8);
des_ncbc_encrypt((des_cblock *) raw,
(des_cblock *) raw, 1600, sched,
(des_cblock *) ivec, DES_DECRYPT);
nbytes += 1600;
}
Speedo(IDC_BE_D_DES_RTP);
}
// IDEA
{
unsigned short iv[4];
sticks = GetTickCount();
nbytes = 0;
running = TRUE;
memset(iv, 0, sizeof(iv));
initcfb_idea(iv, raw, FALSE);
while (running) {
if ((GetTickCount() - sticks) > BenchInterval) {
running = FALSE;
break;
}
ideacfb(raw, 1600);
nbytes += 1600;
}
close_idea();
Speedo(IDC_BE_E_IDEA);
sticks = GetTickCount();
nbytes = 0;
running = TRUE;
memset(iv, 0, sizeof(iv));
initcfb_idea(iv, raw, TRUE);
while (running) {
if ((GetTickCount() - sticks) > BenchInterval) {
running = FALSE;
break;
}
ideacfb(raw, 1600);
nbytes += 1600;
}
close_idea();
Speedo(IDC_BE_D_IDEA);
}
// Blowfish
{
BF_KEY bfkey;
sticks = GetTickCount();
nbytes = 0;
running = TRUE;
BF_set_key(&bfkey, 16, raw);
while (running) {
unsigned char iv[8];
if ((GetTickCount() - sticks) > BenchInterval) {
running = FALSE;
break;
}
memset(iv, 0, sizeof(iv));
BF_cbc_encrypt((unsigned char *) raw,
(unsigned char *) raw,
1600, &bfkey, iv, BF_ENCRYPT);
nbytes += 1600;
}
Speedo(IDC_BE_E_BLOWFISH);
sticks = GetTickCount();
nbytes = 0;
running = TRUE;
BF_set_key(&bfkey, 16, raw);
while (running) {
unsigned char iv[8];
if ((GetTickCount() - sticks) > BenchInterval) {
running = FALSE;
break;
}
memset(iv, 0, sizeof(iv));
BF_cbc_encrypt((unsigned char *) raw,
(unsigned char *) raw,
1600, &bfkey, iv, BF_DECRYPT);
nbytes += 1600;
}
Speedo(IDC_BE_D_BLOWFISH);
}
// Key file
{
int i;
sticks = GetTickCount();
nbytes = 0;
running = TRUE;
setkey(raw);
while (running) {
if ((GetTickCount() - sticks) > BenchInterval) {
running = FALSE;
break;
}
for (i = 0; i < 1600; i++) {
raw[i] ^= out[i];
}
nbytes += 1600;
}
Speedo(IDC_BE_E_KEYFILE);
Speedo(IDC_BE_D_KEYFILE);
}
#endif // CRYPTO
bailOut: SetCursor(ocursor);
}
ShowWindow(GetDlgItem(hwnd, IDC_BE_CANCEL), SW_HIDE);
ShowWindow(GetDlgItem(hwnd, IDC_BE_RUN), SW_SHOW);
EnableWindow(GetDlgItem(hwnd, IDOK), TRUE);
SetFocus(GetDlgItem(hwnd, IDOK));
break;
case ID_HELP:
displayHelpTopic(IDS_HELP_BENCH);
break;
}
}
return FALSE;
}
// BENCHDIALOGUE -- Benchmark dialogue
VOID benchDialogue(HWND hwnd)
{
DialogBox(hInst, MAKEINTRESOURCE(IDD_BENCH), hwnd, benchDlgProc);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -