forked from hiraditya/profile-guided-opt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
32 lines (24 loc) · 659 Bytes
/
test.cpp
File metadata and controls
32 lines (24 loc) · 659 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
* Source copied from http://sysmagazine.com/posts/138132.
*/
#include <iostream>
#include <algorithm>
#include <stdlib.h>
const size_t MB = 1024*1024;
size_t MOD = 0;
unsigned char uniqueNumber () {
static unsigned char number = 0;
return ++ number % MOD;
}
int main (int argc , char ** argv) {
if (argc < 3) {
return 1 ;
}
size_t BLOCK_SIZE = atoi (argv [1]) * MB;
MOD = atoi (argv [2]);
unsigned char* garbage = (unsigned char *) malloc (BLOCK_SIZE);
std:: generate_n (garbage, BLOCK_SIZE, uniqueNumber);
std:: sort (garbage, garbage + BLOCK_SIZE);
free (garbage);
return 0 ;
}