Skip to content

Commit 2f2e76a

Browse files
author
Andres Amaya Garcia
authored
Merge pull request #88 from andresag01/no-cycle-counter
benchmark: remove cycle counter
2 parents 76c033e + 9aca063 commit 2f2e76a

File tree

4 files changed

+59
-104
lines changed

4 files changed

+59
-104
lines changed

benchmark/README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@ You can also compile this example with the [mbed Online Compiler](https://develo
1313
The output in the terminal window should be similar to this:
1414

1515
```
16-
SHA-256 : 1673 KB/s, 70 cycles/byte
17-
SHA-512 : 546 KB/s, 215 cycles/byte
18-
AES-CBC-128 : 1428 KB/s, 82 cycles/byte
19-
AES-CBC-192 : 1260 KB/s, 93 cycles/byte
20-
AES-CBC-256 : 1127 KB/s, 104 cycles/byte
21-
AES-GCM-128 : 486 KB/s, 242 cycles/byte
22-
AES-GCM-192 : 464 KB/s, 253 cycles/byte
23-
AES-GCM-256 : 445 KB/s, 264 cycles/byte
24-
AES-CCM-128 : 610 KB/s, 192 cycles/byte
25-
AES-CCM-192 : 547 KB/s, 214 cycles/byte
26-
AES-CCM-256 : 496 KB/s, 237 cycles/byte
27-
CTR_DRBG (NOPR) : 1139 KB/s, 102 cycles/byte
28-
CTR_DRBG (PR) : 826 KB/s, 142 cycles/byte
29-
HMAC_DRBG SHA-256 (NOPR) : 193 KB/s, 611 cycles/byte
30-
HMAC_DRBG SHA-256 (PR) : 170 KB/s, 695 cycles/byte
16+
SHA-256 : 1673 KB/s
17+
SHA-512 : 546 KB/s
18+
AES-CBC-128 : 1428 KB/s
19+
AES-CBC-192 : 1260 KB/s
20+
AES-CBC-256 : 1127 KB/s
21+
AES-GCM-128 : 486 KB/s
22+
AES-GCM-192 : 464 KB/s
23+
AES-GCM-256 : 445 KB/s
24+
AES-CCM-128 : 610 KB/s
25+
AES-CCM-192 : 547 KB/s
26+
AES-CCM-256 : 496 KB/s
27+
CTR_DRBG (NOPR) : 1139 KB/s
28+
CTR_DRBG (PR) : 826 KB/s
29+
HMAC_DRBG SHA-256 (NOPR) : 193 KB/s
30+
HMAC_DRBG SHA-256 (PR) : 170 KB/s
3131
RSA-2048 : 28 ms/ public
3232
RSA-2048 : 953 ms/private
3333
RSA-4096 : 93 ms/ public

benchmark/main.cpp

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -180,25 +180,12 @@
180180
mbedtls_printf( "FAILED: -0x%04x\r\n", -ret );
181181
#endif
182182

183-
static unsigned long mbedtls_timing_hardclock( void )
184-
{
185-
static int dwt_started = 0;
186-
187-
if( dwt_started == 0 )
188-
{
189-
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
190-
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
191-
}
192-
193-
return( DWT->CYCCNT );
194-
}
195-
196183
static volatile int alarmed;
197184
static void alarm() { alarmed = 1; }
198185

199186
#define TIME_AND_TSC( TITLE, CODE ) \
200187
do { \
201-
unsigned long i, j, tsc; \
188+
unsigned long i; \
202189
Timeout t; \
203190
\
204191
mbedtls_printf( HEADER_FORMAT, TITLE ); \
@@ -208,15 +195,8 @@ do { \
208195
CODE; \
209196
} \
210197
\
211-
tsc = mbedtls_timing_hardclock(); \
212-
for( j = 0; j < 1024; j++ ) \
213-
{ \
214-
CODE; \
215-
} \
216-
\
217-
mbedtls_printf( "%9lu KB/s, %9lu cycles/byte\r\n", \
218-
i * BUFSIZE / 1024, \
219-
( mbedtls_timing_hardclock() - tsc ) / ( j * BUFSIZE ) ); \
198+
mbedtls_printf( "%9lu KB/s\r\n", \
199+
i * BUFSIZE / 1024 ); \
220200
} while( 0 )
221201

222202
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && defined(MBEDTLS_MEMORY_DEBUG)

tests/README.md

Lines changed: 26 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -99,57 +99,32 @@ Please observe above that all the lines that have data that changes from executi
9999
Another example with regular examples is shown below:
100100

101101
```
102-
103-
SHA-256 :\s*\d+ Kb/s,\s*\d+ cycles/byte | SHA-256 : 1922 Kb/s, 61 cycl
104-
105-
SHA-512 :\s*\d+ Kb/s,\s*\d+ cycles/byte | SHA-512 : 614 Kb/s, 191 cycl
106-
107-
AES-CBC-128 :\s*\d+ Kb/s,\s*\d+ cycles/byte | AES-CBC-128 : 1401 Kb/s, 83 cycl
108-
109-
AES-CBC-192 :\s*\d+ Kb/s,\s*\d+ cycles/byte | AES-CBC-192 : 1231 Kb/s, 95 cycl
110-
111-
AES-CBC-256 :\s*\d+ Kb/s,\s*\d+ cycles/byte | AES-CBC-256 : 1097 Kb/s, 106 cycl
112-
113-
AES-GCM-128 :\s*\d+ Kb/s,\s*\d+ cycles/byte | AES-GCM-128 : 429 Kb/s, 273 cycl
114-
115-
AES-GCM-192 :\s*\d+ Kb/s,\s*\d+ cycles/byte | AES-GCM-192 : 412 Kb/s, 285 cycl
116-
117-
AES-GCM-256 :\s*\d+ Kb/s,\s*\d+ cycles/byte | AES-GCM-256 : 395 Kb/s, 297 cycl
118-
119-
AES-CCM-128 :\s*\d+ Kb/s,\s*\d+ cycles/byte | AES-CCM-128 : 604 Kb/s, 194 cycl
120-
121-
AES-CCM-192 :\s*\d+ Kb/s,\s*\d+ cycles/byte | AES-CCM-192 : 539 Kb/s, 217 cycl
122-
123-
AES-CCM-256 :\s*\d+ Kb/s,\s*\d+ cycles/byte | AES-CCM-256 : 487 Kb/s, 241 cycl
124-
125-
CTR_DRBG \(NOPR\) :\s*\d+ Kb/s,\s*\d+ cycles/byte | CTR_DRBG (NOPR) : 1145 Kb/s, 102 cycl
126-
127-
CTR_DRBG \(PR\) :\s*\d+ Kb/s,\s*\d+ cycles/byte | CTR_DRBG (PR) : 821 Kb/s, 142 cycl
128-
129-
HMAC_DRBG SHA-256 \(NOPR\) :\s*\d+ Kb/s,\s*\d+ cycles/byte | HMAC_DRBG SHA-256 (NOPR) : 219 Kb/s, 537 cycl
130-
131-
HMAC_DRBG SHA-256 \(PR\) :\s*\d+ Kb/s,\s*\d+ cycles/byte | HMAC_DRBG SHA-256 (PR) : 193 Kb/s, 612 cycl
132-
133-
RSA-2048 :\s*\d+ ms/ public | RSA-2048 : 30 ms/ public
134-
135-
RSA-2048 :\s*\d+ ms/private | RSA-2048 : 1054 ms/private
136-
137-
RSA-4096 :\s*\d+ ms/ public | RSA-4096 : 101 ms/ public
138-
139-
RSA-4096 :\s*\d+ ms/private | RSA-4096 : 5790 ms/private
140-
141-
ECDHE-secp384r1 :\s*\d+ ms/handshake | ECDHE-secp384r1 : 1023 ms/handshake
142-
143-
ECDHE-secp256r1 :\s*\d+ ms/handshake | ECDHE-secp256r1 : 678 ms/handshake
144-
145-
ECDHE-Curve25519 :\s*\d+ ms/handshake | ECDHE-Curve25519 : 580 ms/handshake
146-
147-
ECDH-secp384r1 :\s*\d+ ms/handshake | ECDH-secp384r1 : 503 ms/handshake
148-
149-
ECDH-secp256r1 :\s*\d+ ms/handshake | ECDH-secp256r1 : 336 ms/handshake
150-
151-
ECDH-Curve25519 :\s*\d+ ms/handshake | ECDH-Curve25519 : 300 ms/handshake
152-
102+
SHA-256 :\s*\d+ KB/s | SHA-256 : 1922 KB/s
103+
SHA-512 :\s*\d+ KB/s | SHA-512 : 614 KB/s
104+
AES-CBC-128 :\s*\d+ KB/s | AES-CBC-128 : 1401 KB/s
105+
AES-CBC-192 :\s*\d+ KB/s | AES-CBC-192 : 1231 KB/s
106+
AES-CBC-256 :\s*\d+ KB/s | AES-CBC-256 : 1097 KB/s
107+
AES-GCM-128 :\s*\d+ KB/s | AES-GCM-128 : 429 KB/s
108+
AES-GCM-192 :\s*\d+ KB/s | AES-GCM-192 : 412 KB/s
109+
AES-GCM-256 :\s*\d+ KB/s | AES-GCM-256 : 395 KB/s
110+
AES-CCM-128 :\s*\d+ KB/s | AES-CCM-128 : 604 KB/s
111+
AES-CCM-192 :\s*\d+ KB/s | AES-CCM-192 : 539 KB/s
112+
AES-CCM-256 :\s*\d+ KB/s | AES-CCM-256 : 487 KB/s
113+
CTR_DRBG \(NOPR\) :\s*\d+ KB/s | CTR_DRBG (NOPR) : 1145 KB/s
114+
CTR_DRBG \(PR\) :\s*\d+ KB/s | CTR_DRBG (PR) : 821 KB/s
115+
HMAC_DRBG SHA-256 \(NOPR\) :\s*\d+ KB/s | HMAC_DRBG SHA-256 (NOPR) : 219 KB/s
116+
HMAC_DRBG SHA-256 \(PR\) :\s*\d+ KB/s | HMAC_DRBG SHA-256 (PR) : 193 KB/s
117+
RSA-2048 :\s*\d+ ms/ public | RSA-2048 : 30 ms/ public
118+
RSA-2048 :\s*\d+ ms/private | RSA-2048 : 1054 ms/private
119+
RSA-4096 :\s*\d+ ms/ public | RSA-4096 : 101 ms/ public
120+
RSA-4096 :\s*\d+ ms/private | RSA-4096 : 5790 ms/private
121+
ECDHE-secp384r1 :\s*\d+ ms/handshake | ECDHE-secp384r1 : 1023 ms/handshake
122+
ECDHE-secp256r1 :\s*\d+ ms/handshake | ECDHE-secp256r1 : 678 ms/handshake
123+
ECDHE-Curve25519 :\s*\d+ ms/handshake | ECDHE-Curve25519 : 580 ms/handshake
124+
ECDH-secp384r1 :\s*\d+ ms/handshake | ECDH-secp384r1 : 503 ms/handshake
125+
ECDH-secp256r1 :\s*\d+ ms/handshake | ECDH-secp256r1 : 336 ms/handshake
126+
ECDH-Curve25519 :\s*\d+ ms/handshake | ECDH-Curve25519 : 300 ms/handshake
127+
DONE | DONE
153128
```
154129

155130
More details about ```htrun``` are [here](https://github.com/ARMmbed/htrun#testing-mbed-os-examples).

tests/benchmark.log

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
SHA-256 :\s*\d+ KB/s,\s*\d+ cycles/byte
2-
SHA-512 :\s*\d+ KB/s,\s*\d+ cycles/byte
3-
AES-CBC-128 :\s*\d+ KB/s,\s*\d+ cycles/byte
4-
AES-CBC-192 :\s*\d+ KB/s,\s*\d+ cycles/byte
5-
AES-CBC-256 :\s*\d+ KB/s,\s*\d+ cycles/byte
6-
AES-GCM-128 :\s*\d+ KB/s,\s*\d+ cycles/byte
7-
AES-GCM-192 :\s*\d+ KB/s,\s*\d+ cycles/byte
8-
AES-GCM-256 :\s*\d+ KB/s,\s*\d+ cycles/byte
9-
AES-CCM-128 :\s*\d+ KB/s,\s*\d+ cycles/byte
10-
AES-CCM-192 :\s*\d+ KB/s,\s*\d+ cycles/byte
11-
AES-CCM-256 :\s*\d+ KB/s,\s*\d+ cycles/byte
12-
CTR_DRBG \(NOPR\) :\s*\d+ KB/s,\s*\d+ cycles/byte
13-
CTR_DRBG \(PR\) :\s*\d+ KB/s,\s*\d+ cycles/byte
14-
HMAC_DRBG SHA-256 \(NOPR\) :\s*\d+ KB/s,\s*\d+ cycles/byte
15-
HMAC_DRBG SHA-256 \(PR\) :\s*\d+ KB/s,\s*\d+ cycles/byte
1+
SHA-256 :\s*\d+ KB/s
2+
SHA-512 :\s*\d+ KB/s
3+
AES-CBC-128 :\s*\d+ KB/s
4+
AES-CBC-192 :\s*\d+ KB/s
5+
AES-CBC-256 :\s*\d+ KB/s
6+
AES-GCM-128 :\s*\d+ KB/s
7+
AES-GCM-192 :\s*\d+ KB/s
8+
AES-GCM-256 :\s*\d+ KB/s
9+
AES-CCM-128 :\s*\d+ KB/s
10+
AES-CCM-192 :\s*\d+ KB/s
11+
AES-CCM-256 :\s*\d+ KB/s
12+
CTR_DRBG \(NOPR\) :\s*\d+ KB/s
13+
CTR_DRBG \(PR\) :\s*\d+ KB/s
14+
HMAC_DRBG SHA-256 \(NOPR\) :\s*\d+ KB/s
15+
HMAC_DRBG SHA-256 \(PR\) :\s*\d+ KB/s
1616
RSA-2048 :\s*\d+ ms/ public
1717
RSA-2048 :\s*\d+ ms/private
1818
RSA-4096 :\s*\d+ ms/ public

0 commit comments

Comments
 (0)