Advertisement
Guest User

Torsten B Christiansen

a guest
Jan 16th, 2008
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.91 KB | None | 0 0
  1. ======================================================
  2. PROGRAM:
  3. ======================================================
  4. #include <stdio.h>
  5. #include <gmp.h>
  6.  
  7. int foo(int a) {
  8. int i;
  9. int res = 0;
  10.  
  11. for (i=0; i<a; ++i)
  12. res += i;
  13.  
  14. return res;
  15. }
  16.  
  17.  
  18. int main(int argc, char * argv[]) {
  19. unsigned int r;
  20. int i;
  21.  
  22. mpz_t a, b;
  23. mpz_init(a);
  24. mpz_init(b);
  25. mpz_set_ui(a, foo(20));
  26. mpz_set_ui(b, 2342343746827346);
  27.  
  28. for (i=0; i<100000000; ++i) {
  29. mpz_add(a, a, b);
  30. }
  31.  
  32. r = mpz_get_ui(a);
  33.  
  34. printf("Int: %i", r);
  35.  
  36. }
  37.  
  38.  
  39. ======================================================
  40. GProf OUTPUT:
  41. ======================================================
  42. Flat profile:
  43.  
  44. Each sample counts as 0.01 seconds.
  45. % cumulative self self total
  46. time seconds seconds calls Ts/call Ts/call name
  47. 101.10 0.35 0.35 main
  48. 0.00 0.35 0.00 100000005 0.00 0.00 data_start
  49. 0.00 0.35 0.00 1 0.00 0.00 foo
  50.  
  51. % the percentage of the total running time of the
  52. time program used by this function.
  53.  
  54. cumulative a running sum of the number of seconds accounted
  55. seconds for by this function and those listed above it.
  56.  
  57. self the number of seconds accounted for by this
  58. seconds function alone. This is the major sort for this
  59. listing.
  60.  
  61. calls the number of times this function was invoked, if
  62. this function is profiled, else blank.
  63.  
  64. self the average number of milliseconds spent in this
  65. ms/call function per call, if this function is profiled,
  66. else blank.
  67.  
  68. total the average number of milliseconds spent in this
  69. ms/call function and its descendents per call, if this
  70. function is profiled, else blank.
  71.  
  72. name the name of the function. This is the minor sort
  73. for this listing. The index shows the location of
  74. the function in the gprof listing. If the index is
  75. in parenthesis it shows where it would appear in
  76. the gprof listing if it were to be printed.
  77.  
  78.  
  79. Call graph (explanation follows)
  80.  
  81.  
  82. granularity: each sample hit covers 2 byte(s) for 2.83% of 0.35 seconds
  83.  
  84. index % time self children called name
  85. <spontaneous>
  86. [1] 100.0 0.35 0.00 main [1]
  87. 0.00 0.00 100000005/100000005 data_start [2]
  88. 0.00 0.00 1/1 foo [3]
  89. -----------------------------------------------
  90. 0.00 0.00 100000005/100000005 main [1]
  91. [2] 0.0 0.00 0.00 100000005 data_start [2]
  92. -----------------------------------------------
  93. 0.00 0.00 1/1 main [1]
  94. [3] 0.0 0.00 0.00 1 foo [3]
  95. -----------------------------------------------
  96.  
  97. This table describes the call tree of the program, and was sorted by
  98. the total amount of time spent in each function and its children.
  99.  
  100. Each entry in this table consists of several lines. The line with the
  101. index number at the left hand margin lists the current function.
  102. The lines above it list the functions that called this function,
  103. and the lines below it list the functions this one called.
  104. This line lists:
  105. index A unique number given to each element of the table.
  106. Index numbers are sorted numerically.
  107. The index number is printed next to every function name so
  108. it is easier to look up where the function in the table.
  109.  
  110. % time This is the percentage of the `total' time that was spent
  111. in this function and its children. Note that due to
  112. different viewpoints, functions excluded by options, etc,
  113. these numbers will NOT add up to 100%.
  114.  
  115. self This is the total amount of time spent in this function.
  116.  
  117. children This is the total amount of time propagated into this
  118. function by its children.
  119.  
  120. called This is the number of times the function was called.
  121. If the function called itself recursively, the number
  122. only includes non-recursive calls, and is followed by
  123. a `+' and the number of recursive calls.
  124.  
  125. name The name of the current function. The index number is
  126. printed after it. If the function is a member of a
  127. cycle, the cycle number is printed between the
  128. function's name and the index number.
  129.  
  130.  
  131. For the function's parents, the fields have the following meanings:
  132.  
  133. self This is the amount of time that was propagated directly
  134. from the function into this parent.
  135.  
  136. children This is the amount of time that was propagated from
  137. the function's children into this parent.
  138.  
  139. called This is the number of times this parent called the
  140. function `/' the total number of times the function
  141. was called. Recursive calls to the function are not
  142. included in the number after the `/'.
  143.  
  144. name This is the name of the parent. The parent's index
  145. number is printed after it. If the parent is a
  146. member of a cycle, the cycle number is printed between
  147. the name and the index number.
  148.  
  149. If the parents of the function cannot be determined, the word
  150. `<spontaneous>' is printed in the `name' field, and all the other
  151. fields are blank.
  152.  
  153. For the function's children, the fields have the following meanings:
  154.  
  155. self This is the amount of time that was propagated directly
  156. from the child into the function.
  157.  
  158. children This is the amount of time that was propagated from the
  159. child's children to the function.
  160.  
  161. called This is the number of times the function called
  162. this child `/' the total number of times the child
  163. was called. Recursive calls by the child are not
  164. listed in the number after the `/'.
  165.  
  166. name This is the name of the child. The child's index
  167. number is printed after it. If the child is a
  168. member of a cycle, the cycle number is printed
  169. between the name and the index number.
  170.  
  171. If there are any cycles (circles) in the call graph, there is an
  172. entry for the cycle-as-a-whole. This entry shows who called the
  173. cycle (as parents) and the members of the cycle (as children.)
  174. The `+' recursive calls entry shows the number of function calls that
  175. were internal to the cycle, and the calls entry for each member shows,
  176. for that member, how many times it was called from other members of
  177. the cycle.
  178.  
  179.  
  180.  
  181. Index by function name
  182.  
  183. [2] data_start [3] foo [1] main
  184.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement