Page MenuHomeFreeBSD
Paste P385

stupid benchmark
ActivePublic

Authored by cem on May 6 2020, 12:53 AM.
Tags
None
Referenced Files
F6463483: raw.txt
May 6 2020, 12:53 AM
Subscribers
None
```c
int main(int argc, char **argv)
{
static const size_t len = 2ull*1024*1024*1024;
char *src = malloc(len);
char dst[10];
int loops;
memset(src, 'A', len - 1);
src[len - 1] = 0;
loops = atoi(argv[1]);
for (int i = 0; i < loops; i++) {
strlcpy(dst, src, sizeof(dst));
}
return (dst[0]+dst[1]);
}
```
(Substituting strlcpy implementation. I verified the optimizer was not cheating and inlining the loop.)
Invoked:
```
for i in $(jot 5) ; do /usr/bin/time ./a.exe 20 ; done
```
```
x dataa
+ datab
+----------------------------------------------------------------------------------------+
|+ |
|+ x |
|+ x |
|+ x |
|+ x x|
|A MA| |
+----------------------------------------------------------------------------------------+
N Min Max Median Avg Stddev
x 5 16.93 17.5 16.99 17.084 0.23479779
+ 5 0.81 0.85 0.85 0.834 0.021908902
Difference at 95.0% confidence
-16.25 +/- 0.243193
-95.1182% +/- 0.149259%
(Student's t, pooled s = 0.166748)
```

Event Timeline

cem created this object in space S1 Global.
cem created this object with edit policy "No One".