From: Robert Oliver Date: 2006-10-25T12:31:50+09:00 Subject: Re: [OT] Re: How do I tell when I'm on Cygwin? ------=_Part_13552_2790719.1161747106582 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Here's my results: The native Ruby (one-click): E:\>ruby benchmark.rb Start Ruby benchmark user system total real intArithmetic i:10000001 intResult:1 8.890000 0.000000 8.890000 ( 9.078000) doubleArithmetic i:11000000.0 doubleResult:10011632.7168688 1.235000 0.000000 1.235000 ( 1.390000) longArithmetic i:11000000 Result:10000000 2.562000 0.015000 2.577000 ( 2.735000) trig i:100000.0 sine:0.860248280789742 cosine:-0.509875372417901 tangent:-1.68717362580256 logarithm:4.99999565703347 squareRoot:316.226184874055 0.547000 0.000000 0.547000 ( 0.546000) io write=10000 read=10000 0.047000 0.016000 0.063000 ( 0.079000) Total Ruby benchmark time: 13.281000 0.031000 13.312000 ( 13.828000) The Cygwin Ruby: $ ruby benchmark.rb Start Ruby benchmark user system total real intArithmetic i:10000001 intResult:1 5.875000 0.000000 5.875000 ( 5.904000) doubleArithmetic i:11000000.0 doubleResult:10011632.7168688 0.844000 0.000000 0.844000 ( 0.844000) longArithmetic i:11000000 Result:10000000 1.515000 0.000000 1.515000 ( 1.538000) trig i:100000.0 sine:0.860248280789742 cosine:-0.509875372417901 tangent:-1.68717362580256 logarithm:4.99999565703347 squareRoot:316.226184874055 0.360000 0.000000 0.360000 ( 0.399000) io write=10000 read=10000 0.015000 0.032000 0.047000 ( 0.051000) Total Ruby benchmark time: 8.609000 0.032000 8.641000 ( 8.736000) The benchmark code (I would love to credit the person who wrote this, but I've had it for quite some time and don't remember where I found it): #! /usr/bin/ruby require "benchmark" include Benchmark intMax = 10000000000 # 1B doubleMin = 10000000000.0 # 10B doubleMax = 11000000000.0 # 11B longMin = 10000000000 # 10B longMax = 11000000000 # 11B trigMax = 10000000.0 # 10M ioMax = 1000000 # 1M # I used these numbers to test as the orig. ones take too long intMax = 10000000 # 1B doubleMin = 10000000.0 # 10B doubleMax = 11000000.0 # 11B longMin = 10000000 # 10B longMax = 11000000 # 11B trigMax = 100000.0 # 10M ioMax = 10000 # 1M def intArithmetic(intMax) i = 1 intResult = 1 while i < intMax intResult = intResult - i i = i + 1 intResult = intResult + i i = i + 1 intResult = intResult * i i = i + 1 intResult = intResult / i i = i + 1 end print " i:", i, "\n" print " intResult:", intResult, "\n" end def doubleArithmetic(doubleMin, doubleMax) i = doubleMin doubleResult = doubleMin while i < doubleMax doubleResult = doubleResult - i i = i + 1.0 doubleResult = doubleResult + i i = i + 1.0 doubleResult = doubleResult * i i = i + 1.0 doubleResult = doubleResult / i i = i + 1.0 end print " i:", i, "\n" print " doubleResult:", doubleResult, "\n" end def longArithmetic(longMin, longMax) i = longMin longResult = longMin while i < longMax longResult = longResult - i i = i + 1 longResult = longResult + i i = i + 1 longResult = longResult * i i = i + 1 longResult = longResult / i i = i + 1 end print " i:", i, "\n" print " Result:", longResult, "\n" end def trig(trigMax) i = 1.0 sine = 0.0 cosine = 0.0 tangent = 0.0 logarithm = 0.0 squareRoot = 0.0 while i < trigMax sine = Math.sin(i) cosine = Math.cos(i) tangent = Math.tan(i) logarithm = Math.log10(i) squareRoot = Math.sqrt(i) i = i + 1.0 end print " i:", i, "\n" print " sine:", sine, "\n" print " cosine:", cosine, "\n" print " tangent:", tangent, "\n" print " logarithm:", logarithm, "\n" print " squareRoot:", squareRoot, "\n" end def io(ioMax) fileName = "TestRuby.txt" myString = "abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefgh\n" linesToWrite = [myString] for i in 2..ioMax linesToWrite.push( myString ) end file = File.open(fileName, 'w') file.puts(linesToWrite) file.close() file = File.open(fileName, 'r') readLines = file.readlines() file.close() print "write=",linesToWrite.length() print " read=",readLines.length() end # Main program begins here puts "Start Ruby benchmark" t = 0 benchmark(" " + CAPTION, 7, FMTSTR) do |x| t = x.report("intArithmetic") { intArithmetic(intMax) } t += x.report("doubleArithmetic") { doubleArithmetic(doubleMin, doubleMax) } t += x.report("longArithmetic") { longArithmetic(longMin, longMax) } t += x.report("trig") { trig(trigMax) } t += x.report("io") { ioTime = io(ioMax) } end print "Total Ruby benchmark time:", t, "\n" puts "End Ruby benchmark" On my computer, Cygwin's Ruby was almost twice as fast. On 10/24/06, Robert Oliver wrote: > > I've found this true before. The Cygwin version simply performs better by > a > significant margin than the one-click. > > I will run some benchmarks again and post as well, as I don't have the old > figures handy. > > > -- > Robert W. Oliver II > President, OCS Solutions, Inc. - Web Hosting and Development > http://www.ocssolutions.com/ > > Toll-Free Phone - 1-800-672-8415 > > OCS Ruby Forums - http://www.rubyforums.com/ > My Blog - http://www.rwoliver.com/ > > -- Robert W. Oliver II President, OCS Solutions, Inc. - Web Hosting and Development http://www.ocssolutions.com/ Toll-Free Phone - 1-800-672-8415 OCS Ruby Forums - http://www.rubyforums.com/ My Blog - http://www.rwoliver.com/ ------=_Part_13552_2790719.1161747106582--