[logback-dev] svn commit: r1690 - logback/trunk/logback-examples/src/main/java/chapter8
noreply.ceki at qos.ch
noreply.ceki at qos.ch
Tue May 6 22:23:32 CEST 2008
Author: ceki
Date: Tue May 6 22:23:31 2008
New Revision: 1690
Added:
logback/trunk/logback-examples/src/main/java/chapter8/
logback/trunk/logback-examples/src/main/java/chapter8/NestedProfilerExample.java
logback/trunk/logback-examples/src/main/java/chapter8/ProfilerUsageExample.java
Log:
- adding profiler examples
Added: logback/trunk/logback-examples/src/main/java/chapter8/NestedProfilerExample.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-examples/src/main/java/chapter8/NestedProfilerExample.java Tue May 6 22:23:31 2008
@@ -0,0 +1,46 @@
+package chapter8;
+
+import ch.qos.logback.classic.stopwatch.Profiler;
+
+public class NestedProfilerExample {
+
+ public static void main(String[] args) {
+ Profiler profiler = new Profiler("BASIC");
+ profiler.start("A");
+ doA();
+
+ profiler.start("B");
+ for (int i = 0; i < 5; i++) {
+ doB(i);
+ }
+ profiler.start("Other");
+ doOther();
+ profiler.stop().print();
+ }
+
+ public void subTask() {
+
+ }
+
+
+ static void doA() {
+ delay(10);
+ }
+
+ static void doB(int millis) {
+ delay(millis);
+ }
+
+ static void doOther() {
+ delay(10);
+ }
+
+
+ static void delay(int millis) {
+ try {
+ Thread.sleep(millis);
+ } catch (InterruptedException e) {
+ }
+ }
+
+}
Added: logback/trunk/logback-examples/src/main/java/chapter8/ProfilerUsageExample.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-examples/src/main/java/chapter8/ProfilerUsageExample.java Tue May 6 22:23:31 2008
@@ -0,0 +1,40 @@
+package chapter8;
+
+import ch.qos.logback.classic.stopwatch.Profiler;
+
+public class ProfilerUsageExample {
+
+ public static void main(String[] args) {
+ Profiler profiler = new Profiler("BASIC");
+ profiler.start("A");
+ doA();
+
+ profiler.start("B");
+ for (int i = 0; i < 5; i++) {
+ doB(i);
+ }
+ profiler.start("Other");
+ doOther();
+ profiler.stop().print();
+ }
+
+ static void doA() {
+ delay(10);
+ }
+
+ static void doB(int millis) {
+ delay(millis);
+ }
+
+ static void doOther() {
+ delay(10);
+ }
+
+
+ static void delay(int millis) {
+ try {
+ Thread.sleep(millis);
+ } catch (InterruptedException e) {
+ }
+ }
+}
More information about the logback-dev
mailing list