File: show_timing.patch

package info (click to toggle)
jedit 5.3.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 14,252 kB
  • ctags: 11,190
  • sloc: java: 98,480; xml: 94,070; makefile: 52; sh: 42; cpp: 6; python: 6
file content (46 lines) | stat: -rw-r--r-- 1,149 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Index: org/gjt/sp/jedit/search/SearchAndReplace.java
===================================================================
--- org/gjt/sp/jedit/search/SearchAndReplace.java	(Revision 21683)
+++ org/gjt/sp/jedit/search/SearchAndReplace.java	(Arbeitskopie)
@@ -853,7 +853,24 @@
 	{
 		return replaceAll(view,false);
 	} //}}}
-	
+
+	private static long mCount;
+	private static long mTime;
+	private static long mStart;
+	private static long mEnd;
+	private static final int mMod = 1;
+	private static void startMeasurement() {
+		mCount++;
+		mStart = System.nanoTime();
+	}
+	private static void stopMeasurement() {
+		mEnd = System.nanoTime();
+		mTime += mEnd-mStart;
+		if(mCount % mMod == 0) {
+			Log.log(Log.DEBUG,null,"Call= " + mCount + " Avg=" + mTime / mCount);
+		}
+	}
+
 	//{{{ replaceAll() method
 	/**
 	 * Replaces all occurrences of the search string with the replacement
@@ -921,6 +938,7 @@
 				// an error occurs
 				int retVal = 0;
 
+				startMeasurement();
 				try
 				{
 					buffer.beginCompoundEdit();
@@ -932,6 +950,7 @@
 				{
 					buffer.endCompoundEdit();
 				}
+				stopMeasurement();
 
 				if(retVal != 0)
 				{