]> gitweb.factorcode.org Git - factor.git/blobdiff - vm/sampling_profiler.hpp
audio.engine.test: cleanup using
[factor.git] / vm / sampling_profiler.hpp
index 86c3d3cc849a7e7c9fb00cfdbf8f888d86363179..161adc37e0668f222349de6af5b158b991502767 100644 (file)
@@ -1,24 +1,42 @@
-namespace factor
-{
+namespace factor {
 
-#define FACTOR_PROFILE_SAMPLES_PER_SECOND 1000
+struct profiling_sample {
+  // Active thread during sample
+  cell thread;
+  // The callstack at safepoint time. Indexes to the beginning and ending
+  // word entries in the vm sample_callstacks array.
+  cell callstack_begin, callstack_end;
 
-struct profiling_sample
-{
-       // Number of samples taken before the safepoint that recorded the sample
-       cell sample_count;
-       // Number of samples taken during GC
-       cell gc_sample_count;
-       // Active context during sample
-       context *ctx;
-       /* The callstack at safepoint time. Indexes to the beginning and ending
-       code_block entries in the vm sample_callstacks array. */
-       cell callstack_begin, callstack_end;
+  // Number of samples taken before the safepoint that recorded the sample
+  fixnum sample_count;
+  // Number of samples taken during GC
+  fixnum gc_sample_count;
+  // Number of samples taken during unoptimized compiler
+  fixnum jit_sample_count;
+  // Number of samples taken during foreign code execution
+  fixnum foreign_sample_count;
+  // Number of samples taken during code execution in non-Factor threads
+  fixnum foreign_thread_sample_count;
 
-       profiling_sample(factor_vm *vm,
-               cell sample_count,
-               cell gc_sample_count,
-               context *ctx);
+  profiling_sample(fixnum sample_count, fixnum gc_sample_count,
+                   fixnum jit_sample_count, fixnum foreign_sample_count,
+                   fixnum foreign_thread_sample_count)
+      : thread(0),
+        callstack_begin(0),
+        callstack_end(0),
+        sample_count(sample_count),
+        gc_sample_count(gc_sample_count),
+        jit_sample_count(jit_sample_count),
+        foreign_sample_count(foreign_sample_count),
+        foreign_thread_sample_count(foreign_thread_sample_count) {}
+
+  profiling_sample record_counts() volatile;
+  void clear_counts() volatile;
+  bool empty() const {
+    return sample_count + gc_sample_count + jit_sample_count +
+               foreign_sample_count + foreign_thread_sample_count ==
+           0;
+  }
 };
 
 }