[macruby-changes] [4174] MacRuby/trunk/perf/perf_method.rb
source_changes at macosforge.org
source_changes at macosforge.org
Fri May 28 14:07:09 PDT 2010
Revision: 4174
http://trac.macosforge.org/projects/ruby/changeset/4174
Author: lsansonetti at apple.com
Date: 2010-05-28 14:07:07 -0700 (Fri, 28 May 2010)
Log Message:
-----------
added poly+super method tests
Modified Paths:
--------------
MacRuby/trunk/perf/perf_method.rb
Modified: MacRuby/trunk/perf/perf_method.rb
===================================================================
--- MacRuby/trunk/perf/perf_method.rb 2010-05-28 01:52:31 UTC (rev 4173)
+++ MacRuby/trunk/perf/perf_method.rb 2010-05-28 21:07:07 UTC (rev 4174)
@@ -89,3 +89,63 @@
i += 1
end
end
+
+class TestPolyMethod1
+ def foo; 1; end
+end
+
+class TestPolyMethod2
+ def foo; 2; end
+end
+
+class TestPolyMethod3 < TestPolyMethod1
+ def foo; 3; end
+end
+
+class TestPolyMethod4 < TestPolyMethod2
+ def foo; 4; end
+end
+
+perf_test('poly') do
+ o1 = TestPolyMethod1.new
+ o2 = TestPolyMethod2.new
+ o3 = TestPolyMethod3.new
+ o4 = TestPolyMethod4.new
+ i = 0
+ while i < 1000000
+ o1.foo; o2.foo; o3.foo; o4.foo
+ o1.foo; o2.foo; o3.foo; o4.foo
+ o1.foo; o2.foo; o3.foo; o4.foo
+ o1.foo; o2.foo; o3.foo; o4.foo
+ i += 1
+ end
+end
+
+class TestSuper1
+ def foo; 42; end
+end
+
+class TestSuper2 < TestSuper1
+ def foo; super; end
+end
+
+class TestSuper3 < TestSuper2
+ def foo; super; end
+end
+
+class TestSuper4 < TestSuper3
+ def foo; super; end
+end
+
+perf_test('super') do
+ o4 = TestSuper4.new
+ o3 = TestSuper3.new
+ i = 0
+ while i < 10000
+ o4.foo; o3.foo; o4.foo; o3.foo
+ o4.foo; o3.foo; o4.foo; o3.foo
+ o4.foo; o3.foo; o4.foo; o3.foo
+ o4.foo; o3.foo; o4.foo; o3.foo
+ i += 1
+ end
+end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100528/bb8c4c22/attachment.html>
More information about the macruby-changes
mailing list