1212import java .util .concurrent .TimeUnit ;
1313import java .util .concurrent .TimeoutException ;
1414import java .util .concurrent .atomic .AtomicInteger ;
15- import java .util .concurrent .atomic .AtomicLong ;
1615
1716public final class TraceRecorder {
1817
@@ -24,8 +23,6 @@ public final class TraceRecorder {
2423 private final TraceWriter writer ;
2524 private final ConcurrentHashMap <String , AtomicInteger > functionCounts = new ConcurrentHashMap <>();
2625 private final AtomicInteger droppedCaptures = new AtomicInteger (0 );
27- private final AtomicLong totalOnEntryNs = new AtomicLong (0 );
28- private final AtomicLong totalSerializationNs = new AtomicLong (0 );
2926 private final int maxFunctionCount ;
3027 private final ExecutorService serializerExecutor ;
3128
@@ -71,8 +68,6 @@ public void onEntry(String className, String methodName, String descriptor,
7168
7269 private void onEntryImpl (String className , String methodName , String descriptor ,
7370 int lineNumber , String sourceFile , Object [] args ) {
74- long entryStart = System .nanoTime ();
75-
7671 String qualifiedName = className + "." + methodName + descriptor ;
7772
7873 // Check per-method count limit
@@ -83,7 +78,6 @@ private void onEntryImpl(String className, String methodName, String descriptor,
8378
8479 // Serialize args — try inline fast path first, fall back to async with timeout
8580 byte [] argsBlob ;
86- long serStart = System .nanoTime ();
8781 argsBlob = Serializer .serializeFast (args );
8882 if (argsBlob == null ) {
8983 // Slow path: async serialization with timeout for complex/unknown types
@@ -104,15 +98,12 @@ private void onEntryImpl(String className, String methodName, String descriptor,
10498 return ;
10599 }
106100 }
107- totalSerializationNs .addAndGet (System .nanoTime () - serStart );
108101
109102 long timeNs = System .nanoTime ();
110103 count .incrementAndGet ();
111104
112105 writer .recordFunctionCall ("call" , methodName , className , sourceFile ,
113106 lineNumber , descriptor , timeNs , argsBlob );
114-
115- totalOnEntryNs .addAndGet (System .nanoTime () - entryStart );
116107 }
117108
118109 public void flush () {
@@ -139,16 +130,5 @@ public void flush() {
139130 System .err .println ("[codeflash-tracer] Captured " + totalCaptures
140131 + " invocations across " + functionCounts .size () + " methods"
141132 + (dropped > 0 ? " (" + dropped + " dropped due to serialization timeout/failure)" : "" ));
142-
143- // Timing summary
144- long onEntryMs = totalOnEntryNs .get () / 1_000_000 ;
145- long serMs = totalSerializationNs .get () / 1_000_000 ;
146- String writerSummary = writer .getTimingSummary ();
147- System .err .println ("[codeflash-tracer] Timing: onEntry=" + onEntryMs + "ms"
148- + " (serialization=" + serMs + "ms)"
149- + (totalCaptures > 0
150- ? " avg=" + String .format ("%.2f" , (double ) onEntryMs / totalCaptures ) + "ms/capture"
151- : "" )
152- + " " + writerSummary );
153133 }
154134}
0 commit comments