-
-
Save vegard/e79b96cefffbfb753da17c4646132fab to your computer and use it in GitHub Desktop.
creduce vs. halfempty benchmark
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <fcntl.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <string.h> | |
#include <set> | |
#include <vector> | |
#if 1 | |
typedef std::vector<int> int_vector; | |
#else | |
typedef std::vector<long int> int_vector; | |
#endif | |
struct foobar { | |
std::set<int_vector> x; | |
foobar() | |
{ | |
int_vector v; | |
v.push_back(123); | |
v.push_back(678); | |
x.insert(v); | |
} | |
}; | |
struct baz { | |
std::set<int_vector> x; | |
baz() | |
{ | |
} | |
int dummy() | |
{ | |
return 123456678; | |
} | |
}; | |
int get_it(foobar *f) | |
{ | |
auto &s = f->x; | |
const int_vector &v = *s.begin(); | |
return v[0]; | |
} | |
int main(int argc, char *argv[]) | |
{ | |
foobar fb; | |
printf("This is the output: %d\n", get_it(&fb)); | |
return 0; | |
} | |
void dummy() | |
{ | |
printf("Hello world!\n"); | |
} | |
struct unused { | |
int xyz; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <set> | |
#include <stdio.h> | |
#include <vector> | |
#if 1 | |
typedef std::vector<int> a; | |
#endif | |
struct b { | |
std::set<a> c; | |
b() { | |
a d; | |
d.push_back(123); | |
c.insert(d); | |
} | |
}; | |
int e(b *f) { | |
auto g = f->c; | |
a d = *g.begin(); | |
return d[0]; | |
} | |
main() { | |
b fb; | |
printf("This is the output: %d\n", e(&fb)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<fcntl.h> |