Page MenuHomeFreeBSD
Authored By
cem
May 6 2020, 12:53 AM
Size
1 KB
Referenced Files
None
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)
```

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2569803
Default Alt Text
raw.txt (1 KB)

Event Timeline