Skip to content

Instantly share code, notes, and snippets.

@marianposaceanu
Last active November 29, 2022 07:52
Show Gist options
  • Save marianposaceanu/9f855da7af730c2cbe3f84a89e751a01 to your computer and use it in GitHub Desktop.
Save marianposaceanu/9f855da7af730c2cbe3f84a89e751a01 to your computer and use it in GitHub Desktop.
# 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)}"
@andreimaxim
Copy link

andreimaxim commented Sep 17, 2021

Ryzen 9 5900X + Windows 10 Pro with WSL 2:

image

Ryzen 9 5900X + Windows 10 Pro with Hyper-V (RHEL 8):

image

Ryzen 9 5900X + Windows 10 Pro with VMWare Workstation Pro 16 (with side-channel mitigations disabled) :

image

@marianposaceanu
Copy link
Author

Petrify 2022-06-12 at 14 54 01

@andreimaxim
Copy link

andreimaxim commented Nov 16, 2022

Ryzen 9 5900X + Fedora 37:

carbon

@marianposaceanu
Copy link
Author

nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment