Support importing from instruments via deep copy (#33)

Instruments has a complex binary file format. If we're interested in just having a nice flamegraph display of the contents and don't care too much about time ordering or symbol file locations, then we can just grab the information we need from the clipboard rather than deal with the binary file format. This also avoids needing to deal with multiple processes or multiple threads.

This PR contains 2 compressed `.trace` files. In each, if you select the top row in the call tree view and hit "Cmd+Shift+C" or go to "Edit -> Deep Copy", then paste into speedscope, you should get the corresponding flamechart.

## Allocations Profile

![image](https://user-images.githubusercontent.com/150329/39796943-5d900c88-530e-11e8-8dea-fa0a44888a64.png)

![image](https://user-images.githubusercontent.com/150329/39796949-65f6a9f4-530e-11e8-8509-64816cebe74c.png)

## Time Profile

![image](https://user-images.githubusercontent.com/150329/39796956-6fd88776-530e-11e8-9978-14aba8e883e1.png)

![image](https://user-images.githubusercontent.com/150329/39796973-8983189e-530e-11e8-8d82-92183c8590f6.png)
This commit is contained in:
Jamie Wong
2018-05-08 22:27:31 -07:00
committed by GitHub
parent 84504f650a
commit 2b9f7ffe1b
11 changed files with 305 additions and 38 deletions
+2
View File
@@ -0,0 +1,2 @@
simple
simple.dSYM
+1
View File
@@ -0,0 +1 @@
*.trace
+2
View File
@@ -0,0 +1,2 @@
simple: simple.cpp
g++ -Wall -g -o $@ $<
+52
View 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;
}