TIMES=20
CVS="cvs -z3 -d :pserver:anonymous@eugen-desktop.nexus:/e co e17 >/dev/null 2>/dev/null"
SVN="svn checkout svn://eugen-desktop.nexus/trunk e17/ >/dev/null 2> /dev/null"
SVN_HTTP="svn checkout http://eugen-desktop.nexus/svn/trunk e17/ >/dev/null 2> /dev/null"
GIT="git-clone git://eugen-desktop/e.git/ e17 >/dev/null 2>/dev/null"
GIT_HTTP="git-clone http://11.1.5.53/e.git/ e17 >/dev/null 2>/dev/null"

def name(object)
  return 'CVS (pserver)' if object==CVS
  return 'Subversion (svnserve)' if object==SVN
  return 'Subversion (webdav)' if object==SVN_HTTP
  return 'Git (git protocol)' if object==GIT
  return 'Git (http)' if object==GIT_HTTP
end

# For every one of the SCMs and methods we test with
for scm in [CVS,SVN,SVN_HTTP,GIT,GIT_HTTP] do
  sum=0.0
  puts("Benchmarking #{name(scm)} with #{TIMES} checkouts...")
  for i in 1..TIMES do
    # We grab the current time, 
    # # run the checkout command then grab the time again
    t1=Time.now
    system(scm)
    t2=Time.now 
    
    # Now we delete what we've just retrieved
    system("rm -rf e17/") 
    
    # Print some status info
    print(".")

    # Update the sum variable
    sum+=t2-t1
  end 
  
  # And the moment we've all been waiting for 
  average_time=sum/TIMES
  puts
  puts("* #{name(scm)} --> average checkout time: #{average_time}s")
end
