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
This commit is contained in:
52
sample/programs/cpp/simple.cpp
Normal file
52
sample/programs/cpp/simple.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user