Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
runtime profile gathering & export simple API. this is enough to get
it to work with Ostrich.
- Loading branch information
Showing
6 changed files
with
182 additions
and
117 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// The HeapsterHelper class is loaded together with the heapster agent | ||
// in order to proxy bytecode-injected calls back into the agent | ||
// library. | ||
// | ||
// TODO: it seems like this should be entirely unnecessary. fix? | ||
|
||
public class Heapster { | ||
public static int isReady = 0; | ||
public static volatile boolean isProfiling = false; | ||
|
||
public static void start() { | ||
isProfiling = true; | ||
} | ||
|
||
public static void stop() { | ||
isProfiling = false; | ||
} | ||
|
||
private static native byte[] _dumpProfile(); | ||
private static native void _newObject(Object thread, Object o); | ||
|
||
public static void newObject(Object obj) { | ||
if (!isProfiling) | ||
return; | ||
|
||
// TODO: can we get a hold of the sizes here? if so, we could do | ||
// the sampling here & never leave bytecode execution. | ||
|
||
Thread thread = Thread.currentThread(); | ||
if (isReady == 1 && thread != null) | ||
_newObject(thread, obj); | ||
} | ||
|
||
public static byte[] dumpProfile() { | ||
return _dumpProfile(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Lifted from google-perftools. | ||
|
||
#include <string> | ||
|
||
using namespace std; | ||
|
||
string StringPrintf(const char* format, ...) { | ||
char buf[10240]; | ||
va_list ap; | ||
va_start(ap, format); | ||
vsnprintf(buf, sizeof(buf), format, ap); | ||
va_end(ap); | ||
return buf; // implicit conversion | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef HEAPSTER_UTIL_H_ | ||
#define HEAPSTER_UTIL_H_ | ||
|
||
std::string StringPrintf(const char* format, ...); | ||
|
||
#endif // HEAPSTER_UTIL_H_ |