Skip to content

Commit ded1e17

Browse files
Wilco1nsz-arm
authored andcommitted
string: Benchmark unaligned memmove
Add benchmarking of forward and backward unaligned memmoves.
1 parent cf3b6b3 commit ded1e17

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

string/bench/memcpy.c

+34
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,40 @@ int main (void)
221221
printf ("\n");
222222
}
223223

224+
printf ("\nUnaligned forwards memmove:\n");
225+
for (int f = 0; funtab[f].name != 0; f++)
226+
{
227+
printf ("%22s (B/ns) ", funtab[f].name);
228+
229+
for (int size = 1024; size <= 32768; size *= 2)
230+
{
231+
uint64_t t = clock_get_ns ();
232+
for (int i = 0; i < ITERS3; i++)
233+
funtab[f].fun (a, a + 256 + (i & 31), size);
234+
t = clock_get_ns () - t;
235+
printf ("%d%c: %.2f ", size < 1024 ? size : size / 1024,
236+
size < 1024 ? 'B' : 'K', (double)size * ITERS3 / t);
237+
}
238+
printf ("\n");
239+
}
240+
241+
242+
printf ("\nUnaligned backwards memmove:\n");
243+
for (int f = 0; funtab[f].name != 0; f++)
244+
{
245+
printf ("%22s (B/ns) ", funtab[f].name);
246+
247+
for (int size = 1024; size <= 32768; size *= 2)
248+
{
249+
uint64_t t = clock_get_ns ();
250+
for (int i = 0; i < ITERS3; i++)
251+
funtab[f].fun (a + 256 + (i & 31), a, size);
252+
t = clock_get_ns () - t;
253+
printf ("%d%c: %.2f ", size < 1024 ? size : size / 1024,
254+
size < 1024 ? 'B' : 'K', (double)size * ITERS3 / t);
255+
}
256+
printf ("\n");
257+
}
224258

225259
return 0;
226260
}

0 commit comments

Comments
 (0)