ruby-prof 0.4.0-mswin32 → 0.4.1-mswin32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. data/README +220 -220
  2. data/Rakefile +3 -3
  3. data/doc/created.rid +1 -1
  4. data/doc/files/LICENSE.html +0 -142
  5. data/doc/files/README.html +2 -2
  6. data/doc/files/examples/flat_txt.html +8 -16
  7. data/doc/files/examples/graph_txt.html +10 -18
  8. data/doc/files/ext/ruby_prof_c.html +1 -1
  9. data/doc/files/lib/ruby-prof/flat_printer_rb.html +1 -1
  10. data/doc/files/lib/ruby-prof/graph_html_printer_rb.html +1 -1
  11. data/doc/files/lib/ruby-prof/graph_printer_rb.html +1 -1
  12. data/examples/flat.txt +55 -57
  13. data/examples/graph.html +827 -827
  14. data/examples/graph.txt +170 -171
  15. data/ext/ruby_prof.c +35 -20
  16. data/lib/ruby-prof/flat_printer.rb +8 -9
  17. data/lib/ruby-prof/graph_html_printer.rb +3 -2
  18. data/lib/ruby-prof/graph_printer.rb +4 -5
  19. data/lib/ruby_prof.so +0 -0
  20. data/test/basic_test.rb +148 -141
  21. data/test/clock_mode_test.rb +72 -72
  22. data/test/duplicate_names_test.rb +37 -0
  23. data/test/module_test.rb +45 -45
  24. data/test/prime.rb +58 -58
  25. data/test/prime_test.rb +23 -23
  26. data/test/printers_test.rb +27 -27
  27. data/test/recursive_test.rb +55 -55
  28. data/test/test_helper.rb +45 -45
  29. data/test/test_suite.rb +10 -9
  30. data/test/thread_test.rb +32 -32
  31. data/test/timing_test.rb +90 -90
  32. metadata +3 -16
  33. data/doc/classes/RubyProf.html +0 -563
  34. data/doc/classes/RubyProf/CallInfo.html +0 -274
  35. data/doc/classes/RubyProf/FlatPrinter.html +0 -207
  36. data/doc/classes/RubyProf/GraphHtmlPrinter.html +0 -538
  37. data/doc/classes/RubyProf/GraphPrinter.html +0 -240
  38. data/doc/classes/RubyProf/MethodInfo.html +0 -556
  39. data/doc/classes/RubyProf/ProfileTask.html +0 -395
  40. data/doc/classes/RubyProf/Result.html +0 -234
  41. data/doc/fr_class_index.html +0 -34
  42. data/doc/fr_file_index.html +0 -39
  43. data/doc/fr_method_index.html +0 -67
  44. data/doc/index.html +0 -24
  45. data/test/test.rb +0 -3
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'test/unit'
4
+ require 'ruby-prof'
5
+ require 'test_helper'
6
+
7
+ class DuplicateNames < Test::Unit::TestCase
8
+ def test_names
9
+ result = RubyProf::profile do
10
+ str = %{module Foo; class Bar; def foo; end end end}
11
+
12
+ eval str
13
+ Foo::Bar.new.foo
14
+ DuplicateNames.class_eval {remove_const :Foo}
15
+
16
+ eval str
17
+ Foo::Bar.new.foo
18
+ DuplicateNames.class_eval {remove_const :Foo}
19
+
20
+ eval str
21
+ Foo::Bar.new.foo
22
+ end
23
+ print_results(result)
24
+
25
+ # There should be 3 foo methods
26
+ methods = result.threads.values.first
27
+
28
+ method_info = methods['DuplicateNames::Foo::Bar#foo']
29
+ assert_not_nil(method_info)
30
+
31
+ method_info = methods['DuplicateNames::Foo::Bar#foo_1']
32
+ assert_not_nil(method_info)
33
+
34
+ method_info = methods['DuplicateNames::Foo::Bar#foo_2']
35
+ assert_not_nil(method_info)
36
+ end
37
+ end
@@ -1,45 +1,45 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'test/unit'
4
- require 'ruby-prof'
5
- require 'test_helper'
6
-
7
-
8
- module Foo
9
- def Foo::hello
10
- end
11
- end
12
-
13
- module Bar
14
- def Bar::hello
15
- Foo::hello
16
- end
17
-
18
- def hello
19
- Bar::hello
20
- end
21
- end
22
-
23
- include Bar
24
-
25
- class BasicTest < Test::Unit::TestCase
26
- def test_nested_modules
27
- result = RubyProf.profile do
28
- hello
29
- end
30
-
31
- methods = result.threads.values.first
32
-
33
- # Length should be 4s
34
- assert_equal(4, methods.length)
35
-
36
- method1 = methods['Bar#hello']
37
- assert_not_nil(method1)
38
-
39
- method1 = methods['<Module::Bar>#hello']
40
- assert_not_nil(method1)
41
-
42
- method1 = methods['<Module::Foo>#hello']
43
- assert_not_nil(method1)
44
- end
45
- end
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'test/unit'
4
+ require 'ruby-prof'
5
+ require 'test_helper'
6
+
7
+
8
+ module Foo
9
+ def Foo::hello
10
+ end
11
+ end
12
+
13
+ module Bar
14
+ def Bar::hello
15
+ Foo::hello
16
+ end
17
+
18
+ def hello
19
+ Bar::hello
20
+ end
21
+ end
22
+
23
+ include Bar
24
+
25
+ class BasicTest < Test::Unit::TestCase
26
+ def test_nested_modules
27
+ result = RubyProf.profile do
28
+ hello
29
+ end
30
+
31
+ methods = result.threads.values.first
32
+
33
+ # Length should be 4s
34
+ assert_equal(4, methods.length)
35
+
36
+ method1 = methods['Bar#hello']
37
+ assert_not_nil(method1)
38
+
39
+ method1 = methods['<Module::Bar>#hello']
40
+ assert_not_nil(method1)
41
+
42
+ method1 = methods['<Module::Foo>#hello']
43
+ assert_not_nil(method1)
44
+ end
45
+ end
@@ -1,58 +1,58 @@
1
- # A silly little test program that finds prime numbers. It
2
- # is intentionally badly designed to show off the use
3
- # or ruby-prof.
4
- #
5
- # Source from http://people.cs.uchicago.edu/~bomb154/154/maclabs/profilers-lab/
6
-
7
- def make_random_array(length, maxnum)
8
- result = Array.new(length)
9
- result.each_index do |i|
10
- result[i] = rand(maxnum)
11
- end
12
-
13
- result
14
- end
15
-
16
- def is_prime(x)
17
- y = 2
18
- y.upto(x-1) do |i|
19
- return false if (x % i) == 0
20
- end
21
- true
22
- end
23
-
24
- def find_primes(arr)
25
- result = arr.select do |value|
26
- is_prime(value)
27
- end
28
- result
29
- end
30
-
31
- def find_largest(primes)
32
- largest = primes.first
33
-
34
- # Intentionally use upto for example purposes
35
- # (upto is also called from is_prime)
36
- 0.upto(primes.length-1) do |i|
37
- sleep(0.02)
38
- prime = primes[i]
39
- if prime > largest
40
- largest = prime
41
- end
42
- end
43
- largest
44
- end
45
-
46
- def run_primes
47
- length = 500
48
- maxnum = 10000
49
-
50
- # Create random numbers
51
- random_array = make_random_array(length, maxnum)
52
-
53
- # Find the primes
54
- primes = find_primes(random_array)
55
-
56
- # Find the largest primes
57
- largest = find_largest(primes)
58
- end
1
+ # A silly little test program that finds prime numbers. It
2
+ # is intentionally badly designed to show off the use
3
+ # or ruby-prof.
4
+ #
5
+ # Source from http://people.cs.uchicago.edu/~bomb154/154/maclabs/profilers-lab/
6
+
7
+ def make_random_array(length, maxnum)
8
+ result = Array.new(length)
9
+ result.each_index do |i|
10
+ result[i] = rand(maxnum)
11
+ end
12
+
13
+ result
14
+ end
15
+
16
+ def is_prime(x)
17
+ y = 2
18
+ y.upto(x-1) do |i|
19
+ return false if (x % i) == 0
20
+ end
21
+ true
22
+ end
23
+
24
+ def find_primes(arr)
25
+ result = arr.select do |value|
26
+ is_prime(value)
27
+ end
28
+ result
29
+ end
30
+
31
+ def find_largest(primes)
32
+ largest = primes.first
33
+
34
+ # Intentionally use upto for example purposes
35
+ # (upto is also called from is_prime)
36
+ 0.upto(primes.length-1) do |i|
37
+ sleep(0.02)
38
+ prime = primes[i]
39
+ if prime > largest
40
+ largest = prime
41
+ end
42
+ end
43
+ largest
44
+ end
45
+
46
+ def run_primes
47
+ length = 500
48
+ maxnum = 10000
49
+
50
+ # Create random numbers
51
+ random_array = make_random_array(length, maxnum)
52
+
53
+ # Find the primes
54
+ primes = find_primes(random_array)
55
+
56
+ # Find the largest primes
57
+ largest = find_largest(primes)
58
+ end
@@ -1,24 +1,24 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'test/unit'
4
- require 'ruby-prof'
5
- require 'prime'
6
- require 'test_helper'
7
-
8
-
9
- # -- Tests ----
10
- class PrimeTest < Test::Unit::TestCase
11
- def test_consistency
12
- result = RubyProf.profile do
13
- run_primes
14
- end
15
-
16
- result.threads.values.each do |methods|
17
- methods.values.each do |method|
18
- check_parent_times(method)
19
- check_parent_calls(method)
20
- check_child_times(method)
21
- end
22
- end
23
- end
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'test/unit'
4
+ require 'ruby-prof'
5
+ require 'prime'
6
+ require 'test_helper'
7
+
8
+
9
+ # -- Tests ----
10
+ class PrimeTest < Test::Unit::TestCase
11
+ def test_consistency
12
+ result = RubyProf.profile do
13
+ run_primes
14
+ end
15
+
16
+ result.threads.values.each do |methods|
17
+ methods.values.each do |method|
18
+ check_parent_times(method)
19
+ check_parent_calls(method)
20
+ check_child_times(method)
21
+ end
22
+ end
23
+ end
24
24
  end
@@ -1,28 +1,28 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'test/unit'
4
- require 'ruby-prof'
5
- require 'prime'
6
- require 'test_helper'
7
-
8
-
9
- # -- Tests ----
10
- class PrintersTest < Test::Unit::TestCase
11
- def test_printer
12
- result = RubyProf.profile do
13
- run_primes
14
- end
15
-
16
- printer = RubyProf::FlatPrinter.new(result)
17
- printer.print(STDOUT)
18
-
19
- printer = RubyProf::GraphHtmlPrinter.new(result)
20
- printer.print(STDOUT)
21
-
22
- printer = RubyProf::GraphPrinter.new(result)
23
- printer.print(STDOUT)
24
-
25
- # we should get here
26
- assert(true)
27
- end
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'test/unit'
4
+ require 'ruby-prof'
5
+ require 'prime'
6
+ require 'test_helper'
7
+
8
+
9
+ # -- Tests ----
10
+ class PrintersTest < Test::Unit::TestCase
11
+ def test_printer
12
+ result = RubyProf.profile do
13
+ run_primes
14
+ end
15
+
16
+ printer = RubyProf::FlatPrinter.new(result)
17
+ printer.print(STDOUT)
18
+
19
+ printer = RubyProf::GraphHtmlPrinter.new(result)
20
+ printer.print(STDOUT)
21
+
22
+ printer = RubyProf::GraphPrinter.new(result)
23
+ printer.print(STDOUT)
24
+
25
+ # we should get here
26
+ assert(true)
27
+ end
28
28
  end
@@ -1,55 +1,55 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'test/unit'
4
- require 'ruby-prof'
5
- require 'timeout'
6
- require 'test_helper'
7
-
8
-
9
- def simple(n)
10
- sleep(1)
11
- n -= 1
12
- return if n == 0
13
- simple(n)
14
- end
15
-
16
- def factorial(n)
17
- if n < 2 then
18
- n
19
- else
20
- n * factorial(n-1)
21
- end
22
- end
23
-
24
-
25
- # -- Tests ----
26
- class RecursiveTest < Test::Unit::TestCase
27
- def test_recursive
28
- result = RubyProf.profile do
29
- simple(3)
30
- end
31
-
32
- result.threads.values.each do |methods|
33
- methods.values.each do |method|
34
- check_parent_times(method)
35
- check_parent_calls(method)
36
- check_child_times(method)
37
- end
38
- end
39
- end
40
-
41
- def test_factorial
42
- result = RubyProf.profile do
43
- # Around 700 on windows causes "stack level too deep" error
44
- factorial(650)
45
- end
46
-
47
- result.threads.values.each do |methods|
48
- methods.values.each do |method|
49
- check_parent_times(method)
50
- check_parent_calls(method)
51
- check_child_times(method)
52
- end
53
- end
54
- end
55
- end
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'test/unit'
4
+ require 'ruby-prof'
5
+ require 'timeout'
6
+ require 'test_helper'
7
+
8
+
9
+ def simple(n)
10
+ sleep(1)
11
+ n -= 1
12
+ return if n == 0
13
+ simple(n)
14
+ end
15
+
16
+ def factorial(n)
17
+ if n < 2 then
18
+ n
19
+ else
20
+ n * factorial(n-1)
21
+ end
22
+ end
23
+
24
+
25
+ # -- Tests ----
26
+ class RecursiveTest < Test::Unit::TestCase
27
+ def test_recursive
28
+ result = RubyProf.profile do
29
+ simple(3)
30
+ end
31
+
32
+ result.threads.values.each do |methods|
33
+ methods.values.each do |method|
34
+ check_parent_times(method)
35
+ check_parent_calls(method)
36
+ check_child_times(method)
37
+ end
38
+ end
39
+ end
40
+
41
+ def test_factorial
42
+ result = RubyProf.profile do
43
+ # Around 700 on windows causes "stack level too deep" error
44
+ factorial(650)
45
+ end
46
+
47
+ result.threads.values.each do |methods|
48
+ methods.values.each do |method|
49
+ check_parent_times(method)
50
+ check_parent_calls(method)
51
+ check_child_times(method)
52
+ end
53
+ end
54
+ end
55
+ end