ruby-prof 0.10.8 → 0.11.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +38 -18
- data/LICENSE +4 -3
- data/README.rdoc +30 -66
- data/Rakefile +47 -54
- data/bin/ruby-prof +24 -4
- data/ext/ruby_prof/extconf.rb +9 -16
- data/ext/ruby_prof/rp_call_info.c +369 -0
- data/ext/ruby_prof/rp_call_info.h +46 -0
- data/ext/ruby_prof/rp_measure.c +48 -0
- data/ext/ruby_prof/rp_measure.h +45 -0
- data/ext/ruby_prof/rp_measure_allocations.c +86 -0
- data/ext/ruby_prof/rp_measure_cpu_time.c +112 -0
- data/ext/ruby_prof/rp_measure_gc_runs.c +87 -0
- data/ext/ruby_prof/rp_measure_gc_time.c +73 -0
- data/ext/ruby_prof/rp_measure_memory.c +81 -0
- data/ext/ruby_prof/rp_measure_process_time.c +71 -0
- data/ext/ruby_prof/rp_measure_wall_time.c +42 -0
- data/ext/ruby_prof/rp_method.c +363 -0
- data/ext/ruby_prof/rp_method.h +55 -0
- data/ext/ruby_prof/rp_stack.c +61 -0
- data/ext/ruby_prof/rp_stack.h +40 -0
- data/ext/ruby_prof/rp_thread.c +113 -0
- data/ext/ruby_prof/rp_thread.h +20 -0
- data/ext/ruby_prof/ruby_prof.c +259 -1398
- data/ext/ruby_prof/ruby_prof.h +54 -190
- data/ext/ruby_prof/version.h +6 -3
- data/lib/1.8/ruby_prof.so +0 -0
- data/lib/1.9/ruby_prof.exp +0 -0
- data/lib/1.9/ruby_prof.ilk +0 -0
- data/lib/1.9/ruby_prof.lib +0 -0
- data/lib/1.9/ruby_prof.pdb +0 -0
- data/lib/1.9/ruby_prof.so +0 -0
- data/lib/ruby-prof.rb +14 -11
- data/lib/ruby-prof/abstract_printer.rb +10 -0
- data/lib/ruby-prof/aggregate_call_info.rb +2 -0
- data/lib/ruby-prof/call_info.rb +2 -0
- data/lib/ruby-prof/call_stack_printer.rb +2 -4
- data/lib/ruby-prof/call_tree_printer.rb +1 -0
- data/lib/ruby-prof/compatibility.rb +134 -0
- data/lib/ruby-prof/dot_printer.rb +7 -7
- data/lib/ruby-prof/flat_printer.rb +7 -7
- data/lib/ruby-prof/flat_printer_with_line_numbers.rb +2 -5
- data/lib/ruby-prof/graph_html_printer.rb +4 -2
- data/lib/ruby-prof/graph_printer.rb +4 -3
- data/lib/ruby-prof/method_info.rb +2 -0
- data/lib/ruby-prof/multi_printer.rb +2 -0
- data/lib/ruby-prof/{result.rb → profile.rb} +3 -1
- data/lib/ruby-prof/rack.rb +1 -0
- data/lib/ruby-prof/symbol_to_proc.rb +2 -0
- data/lib/ruby-prof/task.rb +1 -0
- data/lib/ruby-prof/test.rb +2 -0
- data/lib/ruby_prof.exp +0 -0
- data/lib/ruby_prof.ilk +0 -0
- data/lib/ruby_prof.lib +0 -0
- data/lib/ruby_prof.pdb +0 -0
- data/lib/ruby_prof.so +0 -0
- data/lib/unprof.rb +2 -0
- data/test/aggregate_test.rb +8 -8
- data/test/basic_test.rb +3 -251
- data/test/bug_test.rb +6 -0
- data/test/duplicate_names_test.rb +2 -2
- data/test/dynamic_method_test.rb +61 -0
- data/test/enumerable_test.rb +2 -2
- data/test/exceptions_test.rb +4 -3
- data/test/exclude_threads_test.rb +2 -2
- data/test/exec_test.rb +3 -3
- data/test/line_number_test.rb +5 -5
- data/test/measure_allocations_test.rb +25 -0
- data/test/measure_cpu_time_test.rb +212 -0
- data/test/measure_gc_runs_test.rb +29 -0
- data/test/measure_gc_time_test.rb +29 -0
- data/test/measure_memory_test.rb +36 -0
- data/test/measure_process_time_test.rb +205 -0
- data/test/measure_wall_time_test.rb +209 -0
- data/test/method_elimination_test.rb +2 -2
- data/test/module_test.rb +3 -2
- data/test/multi_printer_test.rb +2 -2
- data/test/no_method_class_test.rb +3 -1
- data/test/prime_test.rb +3 -3
- data/test/printers_test.rb +106 -8
- data/test/recursive_test.rb +7 -6
- data/test/singleton_test.rb +2 -2
- data/test/stack_printer_test.rb +2 -3
- data/test/stack_test.rb +2 -2
- data/test/start_stop_test.rb +2 -2
- data/test/test_helper.rb +81 -0
- data/test/test_suite.rb +34 -29
- data/test/thread_test.rb +24 -23
- data/test/unique_call_path_test.rb +2 -2
- metadata +101 -69
- data/ext/ruby_prof/measure_allocations.h +0 -83
- data/ext/ruby_prof/measure_cpu_time.h +0 -152
- data/ext/ruby_prof/measure_gc_runs.h +0 -76
- data/ext/ruby_prof/measure_gc_time.h +0 -57
- data/ext/ruby_prof/measure_memory.h +0 -101
- data/ext/ruby_prof/measure_process_time.h +0 -63
- data/ext/ruby_prof/measure_wall_time.h +0 -53
- data/ext/ruby_prof/mingw/Rakefile +0 -23
- data/ext/ruby_prof/mingw/build.rake +0 -38
- data/rails/environment/profile.rb +0 -24
- data/rails/example/example_test.rb +0 -9
- data/rails/profile_test_helper.rb +0 -21
- data/test/current_failures_windows +0 -8
- data/test/measurement_test.rb +0 -132
- data/test/ruby-prof-bin +0 -20
@@ -1,76 +0,0 @@
|
|
1
|
-
/* :nodoc:
|
2
|
-
* Copyright (C) 2008 Shugo Maeda <shugo@ruby-lang.org>
|
3
|
-
* Charlie Savage <cfis@savagexi.com>
|
4
|
-
* All rights reserved.
|
5
|
-
*
|
6
|
-
* Redistribution and use in source and binary forms, with or without
|
7
|
-
* modification, are permitted provided that the following conditions
|
8
|
-
* are met:
|
9
|
-
* 1. Redistributions of source code must retain the above copyright
|
10
|
-
* notice, this list of conditions and the following disclaimer.
|
11
|
-
* 2. Redistributions in binary form must reproduce the above copyright
|
12
|
-
* notice, this list of conditions and the following disclaimer in the
|
13
|
-
* documentation and/or other materials provided with the distribution.
|
14
|
-
*
|
15
|
-
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
16
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
17
|
-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
18
|
-
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
19
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
20
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
21
|
-
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
22
|
-
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
23
|
-
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
24
|
-
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
25
|
-
* SUCH DAMAGE. */
|
26
|
-
|
27
|
-
#if defined(HAVE_RB_GC_COLLECTIONS)
|
28
|
-
#define MEASURE_GC_RUNS 5
|
29
|
-
|
30
|
-
static prof_measure_t
|
31
|
-
measure_gc_runs()
|
32
|
-
{
|
33
|
-
return NUM2INT(rb_gc_collections());
|
34
|
-
}
|
35
|
-
|
36
|
-
static double
|
37
|
-
convert_gc_runs(prof_measure_t c)
|
38
|
-
{
|
39
|
-
return c;
|
40
|
-
}
|
41
|
-
|
42
|
-
/* Document-method: prof_measure_gc_runs
|
43
|
-
call-seq:
|
44
|
-
gc_runs -> Integer
|
45
|
-
|
46
|
-
Returns the total number of garbage collections.*/
|
47
|
-
static VALUE
|
48
|
-
prof_measure_gc_runs(VALUE self)
|
49
|
-
{
|
50
|
-
return rb_gc_collections();
|
51
|
-
}
|
52
|
-
|
53
|
-
#elif defined(HAVE_RB_GC_HEAP_INFO)
|
54
|
-
#define MEASURE_GC_RUNS 5
|
55
|
-
|
56
|
-
static prof_measure_t
|
57
|
-
measure_gc_runs()
|
58
|
-
{
|
59
|
-
VALUE h = rb_gc_heap_info();
|
60
|
-
return NUM2UINT(rb_hash_aref(h, rb_str_new2("num_gc_passes")));
|
61
|
-
}
|
62
|
-
|
63
|
-
static double
|
64
|
-
convert_gc_runs(prof_measure_t c)
|
65
|
-
{
|
66
|
-
return c;
|
67
|
-
}
|
68
|
-
|
69
|
-
static VALUE
|
70
|
-
prof_measure_gc_runs(VALUE self)
|
71
|
-
{
|
72
|
-
VALUE h = rb_gc_heap_info();
|
73
|
-
return rb_hash_aref(h, rb_str_new2("num_gc_passes"));
|
74
|
-
}
|
75
|
-
|
76
|
-
#endif
|
@@ -1,57 +0,0 @@
|
|
1
|
-
/* :nodoc:
|
2
|
-
* Copyright (C) 2008 Shugo Maeda <shugo@ruby-lang.org>
|
3
|
-
* Charlie Savage <cfis@savagexi.com>
|
4
|
-
* All rights reserved.
|
5
|
-
*
|
6
|
-
* Redistribution and use in source and binary forms, with or without
|
7
|
-
* modification, are permitted provided that the following conditions
|
8
|
-
* are met:
|
9
|
-
* 1. Redistributions of source code must retain the above copyright
|
10
|
-
* notice, this list of conditions and the following disclaimer.
|
11
|
-
* 2. Redistributions in binary form must reproduce the above copyright
|
12
|
-
* notice, this list of conditions and the following disclaimer in the
|
13
|
-
* documentation and/or other materials provided with the distribution.
|
14
|
-
*
|
15
|
-
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
16
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
17
|
-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
18
|
-
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
19
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
20
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
21
|
-
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
22
|
-
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
23
|
-
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
24
|
-
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
25
|
-
* SUCH DAMAGE. */
|
26
|
-
|
27
|
-
#if defined(HAVE_RB_GC_TIME)
|
28
|
-
#define MEASURE_GC_TIME 6
|
29
|
-
|
30
|
-
static prof_measure_t
|
31
|
-
measure_gc_time()
|
32
|
-
{
|
33
|
-
#if HAVE_LONG_LONG
|
34
|
-
return NUM2LL(rb_gc_time());
|
35
|
-
#else
|
36
|
-
return NUM2LONG(rb_gc_time());
|
37
|
-
#endif
|
38
|
-
}
|
39
|
-
|
40
|
-
static double
|
41
|
-
convert_gc_time(prof_measure_t c)
|
42
|
-
{
|
43
|
-
return (double) c / 1000000;
|
44
|
-
}
|
45
|
-
|
46
|
-
/* Document-method: prof_measure_gc_time
|
47
|
-
call-seq:
|
48
|
-
gc_time -> Integer
|
49
|
-
|
50
|
-
Returns the time spent doing garbage collections in microseconds.*/
|
51
|
-
static VALUE
|
52
|
-
prof_measure_gc_time(VALUE self)
|
53
|
-
{
|
54
|
-
return rb_gc_time();
|
55
|
-
}
|
56
|
-
|
57
|
-
#endif
|
@@ -1,101 +0,0 @@
|
|
1
|
-
/* :nodoc:
|
2
|
-
* Copyright (C) 2008 Alexander Dymo <adymo@pluron.com>
|
3
|
-
*
|
4
|
-
* All rights reserved.
|
5
|
-
*
|
6
|
-
* Redistribution and use in source and binary forms, with or without
|
7
|
-
* modification, are permitted provided that the following conditions
|
8
|
-
* are met:
|
9
|
-
* 1. Redistributions of source code must retain the above copyright
|
10
|
-
* notice, this list of conditions and the following disclaimer.
|
11
|
-
* 2. Redistributions in binary form must reproduce the above copyright
|
12
|
-
* notice, this list of conditions and the following disclaimer in the
|
13
|
-
* documentation and/or other materials provided with the distribution.
|
14
|
-
*
|
15
|
-
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
16
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
17
|
-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
18
|
-
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
19
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
20
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
21
|
-
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
22
|
-
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
23
|
-
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
24
|
-
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
25
|
-
* SUCH DAMAGE. */
|
26
|
-
|
27
|
-
|
28
|
-
#if defined(HAVE_RB_GC_ALLOCATED_SIZE)
|
29
|
-
#define MEASURE_MEMORY 4
|
30
|
-
#define TOGGLE_GC_STATS 1
|
31
|
-
|
32
|
-
static prof_measure_t
|
33
|
-
measure_memory()
|
34
|
-
{
|
35
|
-
#if defined(HAVE_LONG_LONG)
|
36
|
-
return NUM2LL(rb_gc_allocated_size());
|
37
|
-
#else
|
38
|
-
return NUM2ULONG(rb_gc_allocated_size());
|
39
|
-
#endif
|
40
|
-
}
|
41
|
-
|
42
|
-
static double
|
43
|
-
convert_memory(prof_measure_t c)
|
44
|
-
{
|
45
|
-
return (double) c / 1024;
|
46
|
-
}
|
47
|
-
|
48
|
-
/* Document-method: prof_measure_memory
|
49
|
-
call-seq:
|
50
|
-
measure_memory -> int
|
51
|
-
|
52
|
-
Returns total allocated memory in bytes.*/
|
53
|
-
static VALUE
|
54
|
-
prof_measure_memory(VALUE self)
|
55
|
-
{
|
56
|
-
return rb_gc_allocated_size();
|
57
|
-
}
|
58
|
-
|
59
|
-
#elif defined(HAVE_RB_GC_MALLOC_ALLOCATED_SIZE)
|
60
|
-
#define MEASURE_MEMORY 4
|
61
|
-
|
62
|
-
static prof_measure_t
|
63
|
-
measure_memory()
|
64
|
-
{
|
65
|
-
return rb_gc_malloc_allocated_size();
|
66
|
-
}
|
67
|
-
|
68
|
-
static double
|
69
|
-
convert_memory(prof_measure_t c)
|
70
|
-
{
|
71
|
-
return (double) c / 1024;
|
72
|
-
}
|
73
|
-
|
74
|
-
static VALUE
|
75
|
-
prof_measure_memory(VALUE self)
|
76
|
-
{
|
77
|
-
return UINT2NUM(rb_gc_malloc_allocated_size());
|
78
|
-
}
|
79
|
-
|
80
|
-
#elif defined(HAVE_RB_HEAP_TOTAL_MEM)
|
81
|
-
#define MEASURE_MEMORY 4
|
82
|
-
|
83
|
-
static prof_measure_t
|
84
|
-
measure_memory()
|
85
|
-
{
|
86
|
-
return rb_heap_total_mem();
|
87
|
-
}
|
88
|
-
|
89
|
-
static double
|
90
|
-
convert_memory(prof_measure_t c)
|
91
|
-
{
|
92
|
-
return (double) c / 1024;
|
93
|
-
}
|
94
|
-
|
95
|
-
static VALUE
|
96
|
-
prof_measure_memory(VALUE self)
|
97
|
-
{
|
98
|
-
return ULONG2NUM(rb_heap_total_mem());
|
99
|
-
}
|
100
|
-
|
101
|
-
#endif
|
@@ -1,63 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright (C) 2008 Shugo Maeda <shugo@ruby-lang.org>
|
3
|
-
* Charlie Savage <cfis@savagexi.com>
|
4
|
-
* All rights reserved.
|
5
|
-
*
|
6
|
-
* Redistribution and use in source and binary forms, with or without
|
7
|
-
* modification, are permitted provided that the following conditions
|
8
|
-
* are met:
|
9
|
-
* 1. Redistributions of source code must retain the above copyright
|
10
|
-
* notice, this list of conditions and the following disclaimer.
|
11
|
-
* 2. Redistributions in binary form must reproduce the above copyright
|
12
|
-
* notice, this list of conditions and the following disclaimer in the
|
13
|
-
* documentation and/or other materials provided with the distribution.
|
14
|
-
*
|
15
|
-
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
16
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
17
|
-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
18
|
-
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
19
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
20
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
21
|
-
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
22
|
-
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
23
|
-
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
24
|
-
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
25
|
-
* SUCH DAMAGE. */
|
26
|
-
|
27
|
-
#include <time.h>
|
28
|
-
|
29
|
-
#define MEASURE_PROCESS_TIME 0
|
30
|
-
|
31
|
-
static prof_measure_t
|
32
|
-
measure_process_time()
|
33
|
-
{
|
34
|
-
#if defined(__linux__)
|
35
|
-
struct timespec time;
|
36
|
-
clock_gettime(CLOCK_PROCESS_CPUTIME_ID , &time);
|
37
|
-
return time.tv_sec * 1000000000 + time.tv_nsec ;
|
38
|
-
#else
|
39
|
-
return clock();
|
40
|
-
#endif
|
41
|
-
}
|
42
|
-
|
43
|
-
|
44
|
-
static double
|
45
|
-
convert_process_time(prof_measure_t c)
|
46
|
-
{
|
47
|
-
#if defined(__linux__)
|
48
|
-
return (double) c / 1000000000;
|
49
|
-
#else
|
50
|
-
return (double) c / CLOCKS_PER_SEC;
|
51
|
-
#endif
|
52
|
-
}
|
53
|
-
|
54
|
-
/* Document-method: measure_process_time
|
55
|
-
call-seq:
|
56
|
-
measure_process_time -> float
|
57
|
-
|
58
|
-
Returns the process time.*/
|
59
|
-
static VALUE
|
60
|
-
prof_measure_process_time(VALUE self)
|
61
|
-
{
|
62
|
-
return rb_float_new(convert_process_time(measure_process_time()));
|
63
|
-
}
|
@@ -1,53 +0,0 @@
|
|
1
|
-
/* :nodoc:
|
2
|
-
* Copyright (C) 2008 Shugo Maeda <shugo@ruby-lang.org>
|
3
|
-
* Charlie Savage <cfis@savagexi.com>
|
4
|
-
* All rights reserved.
|
5
|
-
*
|
6
|
-
* Redistribution and use in source and binary forms, with or without
|
7
|
-
* modification, are permitted provided that the following conditions
|
8
|
-
* are met:
|
9
|
-
* 1. Redistributions of source code must retain the above copyright
|
10
|
-
* notice, this list of conditions and the following disclaimer.
|
11
|
-
* 2. Redistributions in binary form must reproduce the above copyright
|
12
|
-
* notice, this list of conditions and the following disclaimer in the
|
13
|
-
* documentation and/or other materials provided with the distribution.
|
14
|
-
*
|
15
|
-
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
16
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
17
|
-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
18
|
-
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
19
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
20
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
21
|
-
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
22
|
-
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
23
|
-
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
24
|
-
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
25
|
-
* SUCH DAMAGE. */
|
26
|
-
|
27
|
-
|
28
|
-
#define MEASURE_WALL_TIME 1
|
29
|
-
|
30
|
-
static prof_measure_t
|
31
|
-
measure_wall_time()
|
32
|
-
{
|
33
|
-
struct timeval tv;
|
34
|
-
gettimeofday(&tv, NULL);
|
35
|
-
return tv.tv_sec * 1000000 + tv.tv_usec;
|
36
|
-
}
|
37
|
-
|
38
|
-
static double
|
39
|
-
convert_wall_time(prof_measure_t c)
|
40
|
-
{
|
41
|
-
return (double) c / 1000000;
|
42
|
-
}
|
43
|
-
|
44
|
-
/* Document-method: prof_measure_wall_time
|
45
|
-
call-seq:
|
46
|
-
measure_wall_time -> float
|
47
|
-
|
48
|
-
Returns the wall time.*/
|
49
|
-
static VALUE
|
50
|
-
prof_measure_wall_time(VALUE self)
|
51
|
-
{
|
52
|
-
return rb_float_new(convert_wall_time(measure_wall_time()));
|
53
|
-
}
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# We can't use Ruby's standard build procedures
|
2
|
-
# on Windows because the Ruby executable is
|
3
|
-
# built with VC++ while here we want to build
|
4
|
-
# with MingW. So just roll our own...
|
5
|
-
|
6
|
-
require 'fileutils'
|
7
|
-
require 'rbconfig'
|
8
|
-
|
9
|
-
EXTENSION_NAME = "ruby_prof.#{Config::CONFIG["DLEXT"]}"
|
10
|
-
|
11
|
-
# This is called when the Windows GEM is installed!
|
12
|
-
task :install do
|
13
|
-
# Gems will pass these two environment variables:
|
14
|
-
# RUBYARCHDIR=#{dest_path}
|
15
|
-
# RUBYLIBDIR=#{dest_path}
|
16
|
-
|
17
|
-
dest_path = ENV['RUBYLIBDIR']
|
18
|
-
|
19
|
-
# Copy the extension
|
20
|
-
cp(EXTENSION_NAME, dest_path)
|
21
|
-
end
|
22
|
-
|
23
|
-
task :default => :install
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# We can't use Ruby's standard build procedures
|
2
|
-
# on Windows because the Ruby executable is
|
3
|
-
# built with VC++ while here we want to build
|
4
|
-
# with MingW. So just roll our own...
|
5
|
-
|
6
|
-
require 'rake/clean'
|
7
|
-
require 'rbconfig'
|
8
|
-
|
9
|
-
RUBY_INCLUDE_DIR = Config::CONFIG["archdir"]
|
10
|
-
RUBY_BIN_DIR = Config::CONFIG["bindir"]
|
11
|
-
RUBY_LIB_DIR = Config::CONFIG["libdir"]
|
12
|
-
RUBY_SHARED_LIB = Config::CONFIG["LIBRUBY"]
|
13
|
-
RUBY_SHARED_DLL = RUBY_SHARED_LIB.gsub(/lib$/, 'dll')
|
14
|
-
|
15
|
-
EXTENSION_NAME = "ruby_prof.#{Config::CONFIG["DLEXT"]}"
|
16
|
-
|
17
|
-
CLEAN.include('*.o')
|
18
|
-
CLOBBER.include(EXTENSION_NAME)
|
19
|
-
|
20
|
-
task :default => "ruby_prof"
|
21
|
-
|
22
|
-
SRC = FileList['../*.c']
|
23
|
-
OBJ = SRC.collect do |file_name|
|
24
|
-
File.basename(file_name).ext('o')
|
25
|
-
end
|
26
|
-
|
27
|
-
SRC.each do |srcfile|
|
28
|
-
objfile = File.basename(srcfile).ext('o')
|
29
|
-
file objfile => srcfile do
|
30
|
-
command = "gcc -c -fPIC -O2 -Wall -o #{objfile} -I/usr/local/include #{srcfile} -I#{RUBY_INCLUDE_DIR}"
|
31
|
-
sh "sh -c '#{command}'"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
file "ruby_prof" => OBJ do
|
36
|
-
command = "gcc -shared -o #{EXTENSION_NAME} -L/usr/local/lib #{OBJ} #{RUBY_BIN_DIR}/#{RUBY_SHARED_DLL}"
|
37
|
-
sh "sh -c '#{command}'"
|
38
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# Settings specified here will take precedence over those in config/environment.rb
|
2
|
-
# The profile environment should match the same settings
|
3
|
-
# as the production environment to give a reasonalbe
|
4
|
-
# approximation of performance. However, it should
|
5
|
-
# definitely not use the production databse!
|
6
|
-
|
7
|
-
|
8
|
-
# Cache classes - otherwise your code
|
9
|
-
# will run approximately 5 times slower and the
|
10
|
-
# profiling results will be overwhelmed by Rails
|
11
|
-
# dependency loading mechanism
|
12
|
-
config.cache_classes = true
|
13
|
-
|
14
|
-
# Don't check template timestamps - once again this
|
15
|
-
# is to avoid IO times overwhelming profile results
|
16
|
-
config.action_view.cache_template_loading = true
|
17
|
-
|
18
|
-
# This is debatable, but turn off action controller
|
19
|
-
# caching to see how long it really takes to run
|
20
|
-
# queries and render templates
|
21
|
-
config.action_controller.perform_caching = false
|
22
|
-
|
23
|
-
# Turn off most logging
|
24
|
-
config.log_level = :info
|