Last active
September 24, 2015 08:58
-
-
Save caius/723293 to your computer and use it in GitHub Desktop.
~/bin/rinse_cpus
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
#!/usr/bin/env ruby | |
# Only works on OS X | |
# Spins up enough `yes > /dev/null` instances inside a | |
# `screen` to use 100% of all your cpu cores | |
# | |
# This just starts screen eating your cores, currently | |
# when you're done you need to kill the screen manually. | |
require "tempfile" | |
# Figure out CPU Count | |
CPUCount = `sysctl machdep.cpu.core_count`.split(": ").last.to_i | |
# Use a config to start screen | |
ScreenConfig = <<-EOF | |
startup_message off | |
vbell off | |
#{Array.new(CPUCount) { %{screen -L /bin/sh -c "yes > /dev/null"} }.join("\n")} | |
EOF | |
# Write config into a temp file | |
tfile = Tempfile.new("rinse_cpus.") | |
tfile.puts ScreenConfig | |
tfile.close | |
# Kick off the thing! | |
system("screen -md -S cpu_rinse -c #{tfile.path}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment