Skip to content

Instantly share code, notes, and snippets.

@tubbo
Last active February 13, 2017 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tubbo/f8d5da62eea91f8915cfe287e3e4e51b to your computer and use it in GitHub Desktop.
Save tubbo/f8d5da62eea91f8915cfe287e3e4e51b to your computer and use it in GitHub Desktop.
PERT estimation calculator
#!/usr/bin/env ruby
#
# PERT Calculator v1.0.0
#
# To install, place this file in a directory that is in your $PATH. On
# my machine, I have ~/bin in my $PATH, so that's where `pert` lives.
#
# Example:
#
# $ pert 0.35 0.75 1
#
# optimistic: 0.35
# likely: 0.75
# pessimistic: 1.0
# + QA: 0.11 (15%)
# FINAL: 0.83
if ARGV.empty?
puts "Usage: pert OPTIMISTIC_HOURS LIKELY_HOURS PESSIMISTIC_HOURS"
exit 1
end
QA_TAX = 0.15
BOOST = 4
QUANTITY = 6
optimistic, likely, pessimistic = ARGV.map(&:to_f)
estimate = (optimistic + (BOOST * likely) + pessimistic) / QUANTITY
qa_time = estimate * QA_TAX
estimate += qa_time
[optimistic, likely, pessimistic, estimate, qa_time].map { |num| num.round(2) }
puts " optimistic: #{optimistic}"
puts " likely: #{likely}"
puts "pessimistic: #{pessimistic}"
puts " + QA: #{qa_time.round(2)} (#{(QA_TAX * 100).to_i}%)"
puts " FINAL: #{estimate.round(2)}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment