test.rb in pyroscope-0.0.23 vs test.rb in pyroscope-0.1.0
- old
+ new
@@ -3,90 +3,30 @@
puts "prestart #{Process.pid}"
Pyroscope.configure do |config|
config.app_name = "test.ruby.app{}"
config.server_address = "http://localhost:4040/"
- config.log_level = "debug"
end
-puts "start"
-
-puts "Pyroscope.test_logger 1"
-Pyroscope.test_logger
-Pyroscope.set_logger_level(:debug)
-puts "Pyroscope.test_logger 2"
-Pyroscope.test_logger
-
-
def work(n)
i = 0
while i < n
i += 1
end
end
-def job_0
- work(rand()*1_000_000)
-end
-
-def job_1
- work(rand()*2_000_000)
-end
-
-def sleep_job
- sleep(rand()*10)
-end
-
-def main_loop(b)
- puts "Starting main loop from: #{Process.pid}"
- Pyroscope.set_tag("pid", Process.pid.to_s) if b
- while true
- r = rand
- # if r > 0.9
- # Pyroscope.set_logger_level(:test)
- # end
- if r < 0.1
- sleep_job
- elsif r < 0.5
- puts(" * test.ruby.app{job=0} #{Process.pid}")
- Pyroscope.set_tag("job", "0") if b
- job_0
- Pyroscope.set_tag("job", "") if b
- else
- puts(" * test.ruby.app{job=1} #{Process.pid}")
- Pyroscope.set_tag("job", "1") if b
- job_1
- Pyroscope.set_tag("job", "") if b
- end
+def fast_function
+ Pyroscope.tag_wrapper({ "function" => "fast"}) do
+ work(20_000)
end
end
-fork do
- puts "build_summary:"
- puts Pyroscope.build_summary
- # Pyroscope.configure do |config|
- # config.app_name = "test.ruby.app2{}"
- # config.server_address = "http://localhost:4040/"
- # end
-
- puts "Hello from fork pid: #{Process.pid}"
- sleep 15
- main_loop(false)
+def slow_function
+ Pyroscope.tag({ "function" => "slow"})
+ work(80_000)
+ Pyroscope.remove_tags("function")
end
-# sleep 5
-# if ARGV.first == "subprocess"
-# main_loop(true)
-# else
-# ssh_pid = Kernel.spawn("ruby", "test.rb", "subprocess")
-# puts "spawned #{ssh_pid}"
-
-# sleep(30)
-# puts "killing #{ssh_pid}"
-# Process.kill("TERM", ssh_pid)
-
-
-# end
-
-sleep 15
-puts "The parent process just skips over it: #{Process.pid}"
-main_loop(true)
+while true
+ fast_function
+ slow_function
+end