End-to-End Tracing of Ajax/Java Applications Using DTrace
2017-09-10 21:51
441 查看
End-to-End Tracing of Ajax/Java Applications Using DTrace
Category: UtilityWe posted about using DTrace to profile Firefox in the past, and
today Amit Hurvitz published a piece on Ajax, DTrace and Where They Meet.
JAVASCRIPT
#!/usr/sbin/dtrace -Zs
#pragma D option quiet
#pragma D option switchrate=10
dtrace:::BEGIN
{
jsIndent = 0;
jsFile = "ajax-validation";
javaMethodBoundary= "doGet";
startTimestamp = timestamp;
}
*mozilla$1:::js_function-entry
/basename(copyinstr(arg0)) == jsFile/
{
jsIndent += 2;
printf("%*s -> %s:%s (JavaScript)(elapsed ms: %d)\n", jsIndent, "",
jsFile, copyinstr(arg2), (timestamp - startTimestamp) / 1000);
}
*mozilla$1:::js_function-return
/basename(copyinstr(arg0)) == jsFile/
{
printf("%*s < - %s:%s (JavaScript)(elapsed ms: %d)\n", jsIndent, "",
jsFile, copyinstr(arg2), (timestamp - startTimestamp) / 1000);
jsIndent -= 2;
}
hotspot$2:::method-entry
{
self->strPtr = (char *)copyin(arg1, args[2]+1);
self->strPtr[(int)args[2]] = '\0';
self->classStr = (string)self->strPtr;
self->strPtr = (char *)copyin(arg3, (int)args[4]+1);
self->strPtr[(int)args[4]] = '\0';
self->methodStr = (string)self->strPtr;
}
hotspot$2:::method-entry
/javaMethodBoundary == self->methodStr/
{
self->interested = 1;
self->indent = 0;
}
hotspot$2:::method-entry
/self->interested/
{
self->indent += 2;
printf("%*s -> %s:%s (Java)(elapsed ms: %d)\n", self->indent, "",
self->classStr, self->methodStr, (timestamp - startTimestamp) / 1000);
}
hotspot$2:::method-return
{
self->strPtr = (char *)copyin(arg1, args[2]+1);
self->strPtr[(int)args[2]] = '\0';
self->classStr = (string)self->strPtr;
self->strPtr = (char *)copyin(arg3, (int)args[4]+1);
self->strPtr[(int)args[4]] = '\0';
self->methodStr = (string)self->strPtr;
}
hotspot$2:::method-return
/self->interested/
{
printf("%*s < - %s:%s (Java)(elapsed ms: %d)\n", self->indent, "",
self->classStr, self->methodStr, (timestamp - startTimestamp) / 1000);
self->indent -= 2;
}
hotspot$2:::method-return
/javaMethodBoundary == self->methodStr/
{
self->interested = 0;
/* exit(0); */
}
It then continues to show timings of methods and such. This may not be the simplest solution for debugging, but at least you can get inside the black box when you need too.
相关文章推荐
- End-to-End Tracing of Ajax/Java Applications Using DTrace
- Using AJAX to Improve the Bandwidth Performance of Web Applications
- Notes on <Understanding AJAX: Using JavaScript to Create Rich Internet Applications>
- java.io.EOFException: No content to map to Object due to end of input
- Introduction to Ajax for Java Web Applications
- how-to: resolve "java.lang.OutOfMemoryError: Java heap space" during using beeline && hiveserver2
- Dojo: Using the Dojo JavaScript Library to Build Ajax Applications
- java.io.EOFException: No content to map to Object due to end of input
- Java JDBC - How to connect to Oracle using Service Name instead of SID
- Applications are expected to have a root view controller at the end of application launch
- Java-httpClient警告: Going to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is recommended.
- How to prevent memory leaks when reloading web applications(“java.lang.OutOfMemoryError: PermGen")
- Rapid Web Applications with TurboGears: Using Python to Create Ajax-Powered Sites
- iOS 9出现错误Applications are expected to have a root view controller at the end of application launch
- Unable to determine the principal end of an association between the types '***. The principal end of this association must be explicitly configured using either the relationship fluent API or data annotations.
- Using the Dojo JavaScript Library to Build Ajax Applications一书翻译完毕
- End-to-end internationalization of Web applications
- Applications are expected to have a root view controller at the end of application launch
- Using the Dojo JavaScript Library to Build Ajax Applications一书翻译完毕
- Using Mockito to Unit Test Java Applications