public
Last active

Benchmark break vs. catch-throw vs. begin-rescue-end in ruby

  • Download Gist
bench.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
require 'benchmark'
 
Benchmark.bmbm do |x|
 
x.report('Break') do
1_000_000.times do
break
end
end
 
x.report('Catch/Throw') do
1_000_000.times do
catch(:benchmarking) do
throw(:benchmarking)
end
end
end
 
x.report('Raise/Rescue') do
1_000_000.times do
begin
raise StandardError
rescue
# do nothing
end
end
end
 
end
results.txt
1 2 3 4 5 6 7 8 9 10
Rehearsal ------------------------------------------------
Break 0.000000 0.000000 0.000000 ( 0.000017)
Catch/Throw 0.760000 0.300000 1.060000 ( 1.056713)
Raise/Rescue 10.390000 0.590000 10.980000 ( 11.017974)
-------------------------------------- total: 12.040000sec
 
user system total real
Break 0.000000 0.000000 0.000000 ( 0.000005)
Catch/Throw 0.770000 0.290000 1.060000 ( 1.064175)
Raise/Rescue 9.630000 0.580000 10.210000 ( 10.232384)

<!DOCTYPE html>

Mobile Web App

<!-- Smart App Banner Code / Simple -->

<!-- Smart App Banner Code / With Data -->

<!-- Smart App Banner Code / iTunes Affiliate App Link -->

<!-- Smart App Banner Code / iTunes Affiliate App Link with Data -->

INSTALLATION

Installed with tag in the

of your HTML document

Meta Tag Construction / Attributes-

Name = apple-itunes-app Content = app-id=0000000, app-argument=value, affiliate-data-partnerId=00&siteID=0000

Content arguments if more than app-id alone are separated with a comma, and an optional space for visibility. *Content arguments though set with an equal sign contain no additional quotes. Values are parsed and processed correctly by the lack of white space on either side of the assignment operator within them (=).

Argument Details

app-id A seven character length string generated by the iTunes App Store that is unique to each app

app-argument An optional string of any value that will be accessible to the app when it is launched via the "open" button found on the banner in cases where the app is already installed

affiliate-data This argument processes two values. Your affiliate partner ID for crediting any actions to your account, and your web app's site ID for tracking in the case your account manages multiple sites, and/or your site handles multiple affiliate accounts.

Affiliate Data Parts These values are both processed as one value under affiliate data, and so must be kept together as a single string value with no white space. Use an ampersand (&) to hold them together

partnerId A 2 character length unique ID for your affiliate partner account

siteID A 4 character length unique ID for your website or web app

1 2 3 4 5 6

7

8 9

10

11 12

13

14 15

16

17 18 19 20 21 22 23 24 25

26 27 28 29 30 31 32 33 34

35 36

37

38

39 40 41 42 43

44 45 46

47

48 49 50

51

52

53 54 55

56

57 58 59

60 61 62

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.