aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Mastrangelo <carl-mastrangelo@users.noreply.github.com>2023-03-19 19:12:52 -0700
committerGitHub <noreply@github.com>2023-03-19 19:12:52 -0700
commit9aaeec4530e0834bfd5e10eb24991fdc3939468b (patch)
treeb34906fc8734759ef856f86dc229f1fbcc605437
parent1ad192ab82a2503bad7b74661a810291b773a0f8 (diff)
downloadperfmark-9aaeec4530e0834bfd5e10eb24991fdc3939468b.tar.gz
update docs (#217)
-rw-r--r--README.md4
-rw-r--r--api/src/main/java/io/perfmark/PerfMark.java26
2 files changed, 11 insertions, 19 deletions
diff --git a/README.md b/README.md
index 69bd13c..b7747ba 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,7 @@ tracing function calls to their code to see how long each part takes.
wakes up and executes work on another thread. PerfMark allows users to express this
relationship explicitly, making for a clear picture of how code flows.
-* **Small Library Size**: The PerfMark tracing API is only *5 KB* in size, and has minimal
+* **Small Library Size**: The PerfMark tracing API is only *7 KB* in size, and has minimal
dependencies making it easy to include in other projects. If no backend for recording the trace
is present, the library safely disables itself.
@@ -93,7 +93,7 @@ To view the traces in your browser, generate the HTML:
The output looks like:
-![PerfMark Hummingbird](doc/screenshot.png "PerfMark")
+![PerfMark Trace View](doc/screenshot.png "PerfMark")
## Configuration
PerfMark provides some System Properties that allow controlling how it initializes. These can be set
diff --git a/api/src/main/java/io/perfmark/PerfMark.java b/api/src/main/java/io/perfmark/PerfMark.java
index c5b0230..a064e98 100644
--- a/api/src/main/java/io/perfmark/PerfMark.java
+++ b/api/src/main/java/io/perfmark/PerfMark.java
@@ -26,11 +26,8 @@ import java.lang.reflect.Method;
* be traced using the start and stop methods. For example:
*
* <pre>{@code
- * PerfMark.startTask("parseMessage");
- * try {
+ * try (var close = PerfMark.traceTask("parseMessage")) {
* message = parse(bytes);
- * } finally {
- * PerfMark.stopTask("parseMessage");
* }
* }</pre>
*
@@ -60,21 +57,15 @@ import java.lang.reflect.Method;
* example:
*
* <pre>{@code
- * PerfMark.startTask("handleMessage");
- * try {
+ * try (var close = PerfMark.traceTask("handleMessage")) {
* Link link = PerfMark.linkOut();
- * message = parse(bytes);
+ * var message = parse(bytes);
* executor.execute(() -> {
- * PerfMark.startTask("processMessage");
- * try {
+ * try (var closeInner = PerfMark.traceTask("processMessage")) {
* PerfMark.linkIn(link);
* handle(message);
- * } finally {
- * PerfMark.stopTask("processMessage");
* }
* });
- * } finally {
- * PerfMark.stopTask("handleMessage");
* }
* }</pre>
*
@@ -419,10 +410,11 @@ public final class PerfMark {
* <p>Recording the amount of work done in a task:
*
* <pre>
- * PerfMark.startTask("read");
- * byte[] data = file.read();
- * PerfMark.attachTag(PerfMark.createTag("bytes read", data.length));
- * PerfMark.stopTask("read");
+ * byte[] data;
+ * try (var close = PerfMark.traceTask("read")) {
+ * data = file.read();
+ * PerfMark.attachTag(PerfMark.createTag("bytes read", data.length));
+ * }
* </pre>
*
* <p>Recording a tag which may be absent on an exception: