Files
SpeedScope/sample/programs/cpp/simple.cpp
Jamie Wong f9032f4100 Reorganize sample directory (#34)
This should help keep things organized as speedscope supports more languages & more formats

Test Plan: Try importing from every single file type, see that the link to load the example profile still works
2018-05-08 23:13:38 -07:00

53 lines
661 B
C++

#include <cstdlib>
using namespace std;
void leakMemory() {
for (int i = 0; i < 100; i++) {
malloc(1024);
}
}
void alpha() {
leakMemory();
int z = 3;
for (int i = 0; i < 100000; i++) {
z *= 3;
}
}
void beta() {
leakMemory();
int z = 3;
for (int i = 0; i < 100000; i++) {
z *= 3;
}
}
void delta() {
leakMemory();
int z = 3;
for (int i = 0; i < 100000; i++) {
z *= 3;
}
alpha();
beta();
}
void gamma() {
leakMemory();
int z = 3;
for (int i = 0; i < 100000; i++) {
z *= 3;
}
}
int main(int argc, char* argv[]) {
while (true) {
alpha();
beta();
delta();
gamma();
}
return 0;
}