Last active
November 29, 2022 07:52
-
-
Save marianposaceanu/9f855da7af730c2cbe3f84a89e751a01 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A simple way to measure start-up time from inside Java application | |
# credits: | |
# - https://stackoverflow.com/questions/39321345/how-do-i-measure-jvm-startup-time | |
# | |
# How to run: | |
# | |
# 0. install JRuby (brew, rvm, etc.) e.g. `rvm install jruby-9.2.11.1` | |
# 1. download this script | |
# 2. in the shell run `for i in {1..10}; do ruby jruby_start_up.rb; done | awk '{ total += $1; count++ } END { print total/count }'` | |
# => 1673.9 | |
require 'java' | |
java_import java.lang.System | |
java_import java.lang.management.ManagementFactory | |
current_time = System.currentTimeMillis | |
vm_start_time = ManagementFactory.getRuntimeMXBean.getStartTime | |
# For debug: | |
# puts "System info JRUBY_OPTS='#{ENV['JRUBY_OPTS']}'" | |
# puts "#{(current_time - vm_start_time)} ms" | |
puts "#{(current_time - vm_start_time)}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ryzen 9 5900X + Fedora 37: