tioga 1.11 → 1.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. data/Tioga_README +58 -35
  2. data/{split/scripts → bin}/tioga +1 -1
  3. data/{split → ext/Dobjects}/Dtable/dtable.c +81 -15
  4. data/{split → ext/Dobjects}/Dtable/dtable_intern.h +0 -0
  5. data/ext/Dobjects/Dtable/extconf.rb +7 -0
  6. data/{split → ext/Dobjects}/Dtable/include/dtable.h +0 -0
  7. data/{split → ext/Dobjects}/Dvector/dvector.c +361 -51
  8. data/{split → ext/Dobjects}/Dvector/dvector_intern.h +0 -0
  9. data/ext/Dobjects/Dvector/extconf.rb +22 -0
  10. data/{split/Dtable → ext/Dobjects/Dvector/include}/dvector.h +0 -0
  11. data/ext/Dobjects/Function/extconf.rb +7 -0
  12. data/{split → ext/Dobjects}/Function/function.c +636 -11
  13. data/{split → ext/Dobjects}/Function/joint_qsort.c +0 -0
  14. data/ext/Flate/extconf.rb +26 -0
  15. data/{split → ext}/Flate/flate.c +7 -3
  16. data/{split → ext}/Flate/flate_intern.h +0 -0
  17. data/{split → ext}/Flate/include/flate.h +0 -0
  18. data/ext/Flate/zlib/adler32.c +149 -0
  19. data/ext/Flate/zlib/compress.c +79 -0
  20. data/ext/Flate/zlib/crc32.c +423 -0
  21. data/ext/Flate/zlib/crc32.h +441 -0
  22. data/ext/Flate/zlib/deflate.c +1736 -0
  23. data/ext/Flate/zlib/deflate.h +331 -0
  24. data/ext/Flate/zlib/gzio.c +1026 -0
  25. data/ext/Flate/zlib/infback.c +623 -0
  26. data/ext/Flate/zlib/inffast.c +318 -0
  27. data/ext/Flate/zlib/inffast.h +11 -0
  28. data/ext/Flate/zlib/inffixed.h +94 -0
  29. data/ext/Flate/zlib/inflate.c +1368 -0
  30. data/ext/Flate/zlib/inflate.h +115 -0
  31. data/ext/Flate/zlib/inftrees.c +329 -0
  32. data/ext/Flate/zlib/inftrees.h +55 -0
  33. data/ext/Flate/zlib/trees.c +1219 -0
  34. data/ext/Flate/zlib/trees.h +128 -0
  35. data/ext/Flate/zlib/uncompr.c +61 -0
  36. data/ext/Flate/zlib/zlib.h +1357 -0
  37. data/ext/Flate/zlib/zutil.c +318 -0
  38. data/ext/Flate/zlib/zutil.h +269 -0
  39. data/ext/Tioga/FigureMaker/__shared_axes.c +1373 -0
  40. data/ext/Tioga/FigureMaker/__shared_makers.c +1303 -0
  41. data/{split/Tioga/pdf_font_dicts.c → ext/Tioga/FigureMaker/__shared_pdf_font_dicts.c} +0 -0
  42. data/{split/Tioga/pdfcolor.c → ext/Tioga/FigureMaker/__shared_pdfcolor.c} +0 -0
  43. data/{split/Tioga/pdfcoords.c → ext/Tioga/FigureMaker/__shared_pdfcoords.c} +0 -0
  44. data/{split/Tioga/pdffile.c → ext/Tioga/FigureMaker/__shared_pdffile.c} +0 -0
  45. data/{split/Tioga/pdfimage.c → ext/Tioga/FigureMaker/__shared_pdfimage.c} +0 -0
  46. data/{split/Tioga/pdfpath.c → ext/Tioga/FigureMaker/__shared_pdfpath.c} +0 -0
  47. data/{split/Tioga/pdftext.c → ext/Tioga/FigureMaker/__shared_pdftext.c} +0 -0
  48. data/{split/Tioga/texout.c → ext/Tioga/FigureMaker/__shared_texout.c} +0 -0
  49. data/ext/Tioga/FigureMaker/extconf.rb +7 -0
  50. data/{split/Tioga → ext/Tioga/FigureMaker}/figures.c +14 -2
  51. data/{split/Tioga → ext/Tioga/FigureMaker}/figures.h +0 -0
  52. data/{split/Tioga → ext/Tioga/FigureMaker}/generic.c +1 -2
  53. data/{split/Tioga → ext/Tioga/FigureMaker}/generic.h +0 -1
  54. data/{split/Tioga → ext/Tioga/FigureMaker}/init.c +0 -0
  55. data/{split/Tioga → ext/Tioga/FigureMaker}/pdfs.h +0 -0
  56. data/{split/Tioga → ext/Tioga/FigureMaker/shared}/axes.c +32 -7
  57. data/{split/Tioga → ext/Tioga/FigureMaker/shared}/makers.c +2 -2
  58. data/ext/Tioga/FigureMaker/shared/pdf_font_dicts.c +18253 -0
  59. data/ext/Tioga/FigureMaker/shared/pdfcolor.c +904 -0
  60. data/ext/Tioga/FigureMaker/shared/pdfcoords.c +518 -0
  61. data/ext/Tioga/FigureMaker/shared/pdffile.c +451 -0
  62. data/ext/Tioga/FigureMaker/shared/pdfimage.c +539 -0
  63. data/ext/Tioga/FigureMaker/shared/pdfpath.c +766 -0
  64. data/ext/Tioga/FigureMaker/shared/pdftext.c +710 -0
  65. data/ext/Tioga/FigureMaker/shared/texout.c +533 -0
  66. data/{split/Tioga → ext/Tioga/FigureMaker}/wrappers.c +5 -5
  67. data/{split/Tioga → ext/Tioga/FigureMaker}/wrappers.h +0 -0
  68. data/{split/Dtable → ext/includes}/defs.h +0 -0
  69. data/{split/Dtable → ext/includes}/namespace.h +0 -0
  70. data/{split/Dtable → ext/includes}/safe_double.h +0 -0
  71. data/{split → ext/includes}/symbols.c +0 -1
  72. data/{split/Dtable → ext/includes}/symbols.h +0 -0
  73. data/{split/Dtable/lib → lib/Dobjects}/Dtable_extras.rb +0 -0
  74. data/{split/Dvector/lib → lib/Dobjects}/Dvector_extras.rb +1 -0
  75. data/{split/Function/lib → lib/Dobjects}/Function_extras.rb +0 -0
  76. data/{split/Dvector/lib → lib/Dobjects}/Numeric_extras.rb +0 -0
  77. data/{split/Tioga/lib → lib/Tioga}/Arcs_and_Circles.rb +0 -0
  78. data/{split/Tioga/lib → lib/Tioga}/ColorConstants.rb +0 -0
  79. data/{split/Tioga/lib → lib/Tioga}/Colorbars.rb +0 -0
  80. data/{split/Tioga/lib → lib/Tioga}/Colormaps.rb +0 -0
  81. data/{split/Tioga/lib → lib/Tioga}/Coordinate_Conversions.rb +0 -0
  82. data/{split/Tioga/lib → lib/Tioga}/Creating_Paths.rb +0 -0
  83. data/{split/Tioga/lib → lib/Tioga}/Doc.rb +0 -0
  84. data/{split/Tioga/lib → lib/Tioga}/Executive.rb +0 -0
  85. data/{split/Tioga/lib → lib/Tioga}/FigMkr.rb +13 -70
  86. data/{split/Tioga/lib → lib/Tioga}/FigureConstants.rb +0 -0
  87. data/{split/Tioga/lib → lib/Tioga}/Figures_and_Plots.rb +0 -0
  88. data/{split/Tioga/lib → lib/Tioga}/Images.rb +0 -0
  89. data/{split/Tioga/lib → lib/Tioga}/Legends.rb +0 -0
  90. data/{split/Tioga/lib → lib/Tioga}/MarkerConstants.rb +0 -0
  91. data/{split/Tioga/lib → lib/Tioga}/Markers.rb +0 -0
  92. data/{split/Tioga/lib → lib/Tioga}/Page_Frame_Bounds.rb +0 -0
  93. data/{split/Tioga/lib → lib/Tioga}/Rectangles.rb +0 -0
  94. data/{split/Tioga/lib → lib/Tioga}/Shading.rb +0 -0
  95. data/{split/Tioga/lib → lib/Tioga}/Special_Paths.rb +0 -0
  96. data/{split/Tioga/lib → lib/Tioga}/Strokes.rb +0 -0
  97. data/{split/Tioga/lib → lib/Tioga}/TeX_Text.rb +0 -0
  98. data/{split/Tioga/lib → lib/Tioga}/TexPreamble.rb +0 -0
  99. data/{split/Tioga/lib → lib/Tioga}/Titles_and_Labels.rb +0 -0
  100. data/{split/Tioga/lib → lib/Tioga}/Transparency.rb +0 -0
  101. data/{split/Tioga/lib → lib/Tioga}/Using_Paths.rb +0 -0
  102. data/{split/Tioga/lib → lib/Tioga}/Utils.rb +74 -0
  103. data/{split/Tioga/lib → lib/Tioga}/X_and_Y_Axes.rb +0 -0
  104. data/{split/Tioga/lib → lib/Tioga}/irb_tioga.rb +0 -0
  105. data/{split/Tioga/lib → lib/Tioga}/maker.rb +0 -0
  106. data/{split/Tioga/lib → lib/Tioga}/tioga.rb +0 -0
  107. data/{split/Tioga/lib → lib/Tioga}/tioga_ui.rb +0 -0
  108. data/{split/Tioga/lib → lib/Tioga}/tioga_ui_cmds.rb +0 -0
  109. data/tests/Icon_Test.pdf +0 -0
  110. data/tests/benchmark_dvector_reads.rb +20 -42
  111. data/tests/tc_Dvector.rb +45 -4
  112. data/tests/tc_Flate.rb +4 -5
  113. data/tests/tc_Function.rb +79 -0
  114. data/tests/vg.log +1453 -0
  115. metadata +141 -122
  116. data/split/Dtable/extconf.rb +0 -4
  117. data/split/Dvector/defs.h +0 -39
  118. data/split/Dvector/extconf.rb +0 -4
  119. data/split/Dvector/include/dvector.h +0 -77
  120. data/split/Dvector/namespace.h +0 -59
  121. data/split/Dvector/safe_double.h +0 -104
  122. data/split/Dvector/symbols.h +0 -52
  123. data/split/Flate/defs.h +0 -39
  124. data/split/Flate/extconf.rb +0 -19
  125. data/split/Flate/namespace.h +0 -59
  126. data/split/Flate/safe_double.h +0 -104
  127. data/split/Flate/symbols.h +0 -52
  128. data/split/Function/defs.h +0 -39
  129. data/split/Function/dvector.h +0 -77
  130. data/split/Function/extconf.rb +0 -4
  131. data/split/Function/namespace.h +0 -59
  132. data/split/Function/safe_double.h +0 -104
  133. data/split/Function/symbols.h +0 -52
  134. data/split/Tioga/defs.h +0 -39
  135. data/split/Tioga/dtable.h +0 -35
  136. data/split/Tioga/dvector.h +0 -77
  137. data/split/Tioga/extconf.rb +0 -4
  138. data/split/Tioga/flate.h +0 -98
  139. data/split/Tioga/mk_tioga_sty.rb +0 -53
  140. data/split/Tioga/namespace.h +0 -59
  141. data/split/Tioga/safe_double.h +0 -104
  142. data/split/Tioga/symbols.h +0 -52
  143. data/split/defs.h +0 -39
  144. data/split/extconf.rb +0 -125
  145. data/split/mkmf2.rb +0 -1623
  146. data/split/namespace.h +0 -59
  147. data/split/safe_double.h +0 -104
  148. data/split/symbols.h +0 -52
@@ -77,7 +77,7 @@ OBJ_PTR FM_private_make_portfolio(OBJ_PTR fmkr, OBJ_PTR name, OBJ_PTR fignums, O
77
77
  // makers.c
78
78
  OBJ_PTR FM_private_make_contour(OBJ_PTR fmkr, OBJ_PTR gaps,
79
79
  OBJ_PTR xs, OBJ_PTR ys, OBJ_PTR zs, OBJ_PTR z_level, OBJ_PTR legit, OBJ_PTR method) { int ierr=0;
80
- return c_private_make_contour(fmkr, Get_FM(fmkr, &ierr), gaps, xs, ys, zs, Number_to_double(z_level, &ierr),
80
+ return c_private_make_contour(Qnil, NULL, gaps, xs, ys, zs, Number_to_double(z_level, &ierr),
81
81
  legit, Number_to_int(method, &ierr), &ierr); }
82
82
  OBJ_PTR FM_private_make_steps(OBJ_PTR fmkr, OBJ_PTR Xvec_data, OBJ_PTR Yvec_data,
83
83
  OBJ_PTR xfirst, OBJ_PTR yfirst, OBJ_PTR xlast, OBJ_PTR ylast) { int ierr=0;
@@ -120,9 +120,9 @@ OBJ_PTR FM_get_color_from_colormap(OBJ_PTR fmkr, OBJ_PTR color_map, OBJ_PTR colo
120
120
  OBJ_PTR FM_convert_to_colormap(OBJ_PTR fmkr, OBJ_PTR Rs, OBJ_PTR Gs, OBJ_PTR Bs) { int ierr=0;
121
121
  return c_convert_to_colormap(fmkr, Get_FM(fmkr, &ierr), Rs, Gs, Bs, &ierr); }
122
122
  OBJ_PTR FM_hls_to_rgb(OBJ_PTR fmkr, OBJ_PTR hls_vec) { int ierr=0;
123
- return c_hls_to_rgb(fmkr, Get_FM(fmkr, &ierr), hls_vec, &ierr); }
123
+ return c_hls_to_rgb(Qnil, NULL, hls_vec, &ierr); }
124
124
  OBJ_PTR FM_rgb_to_hls(OBJ_PTR fmkr, OBJ_PTR rgb_vec) { int ierr=0;
125
- return c_rgb_to_hls(fmkr, Get_FM(fmkr, &ierr), rgb_vec, &ierr); }
125
+ return c_rgb_to_hls(Qnil, NULL, rgb_vec, &ierr); }
126
126
  OBJ_PTR FM_title_color_set(OBJ_PTR fmkr, OBJ_PTR val) { int ierr=0;
127
127
  c_title_color_set(fmkr, Get_FM(fmkr, &ierr), val, &ierr); RETURN_NIL; }
128
128
  OBJ_PTR FM_title_color_get(OBJ_PTR fmkr) { int ierr=0;
@@ -155,11 +155,11 @@ OBJ_PTR FM_yaxis_labels_color_get(OBJ_PTR fmkr) { int ierr=0;
155
155
  return c_yaxis_labels_color_get(fmkr, Get_FM(fmkr, &ierr), &ierr); }
156
156
 
157
157
  OBJ_PTR FM_string_hls_to_rgb_bang(OBJ_PTR fmkr, OBJ_PTR str) { int ierr=0;
158
- c_string_hls_to_rgb_bang(fmkr, Get_FM(fmkr, &ierr),
158
+ c_string_hls_to_rgb_bang(Qnil, NULL,
159
159
  (unsigned char *)String_Ptr(str, &ierr), String_Len(str, &ierr), &ierr);
160
160
  return str; }
161
161
  OBJ_PTR FM_string_rgb_to_hls_bang(OBJ_PTR fmkr, OBJ_PTR str) { int ierr=0;
162
- c_string_rgb_to_hls_bang(fmkr, Get_FM(fmkr, &ierr),
162
+ c_string_rgb_to_hls_bang(Qnil, NULL,
163
163
  (unsigned char *)String_Ptr(str, &ierr), String_Len(str, &ierr), &ierr);
164
164
  return str; }
165
165
 
File without changes
File without changes
File without changes
File without changes
@@ -20,7 +20,6 @@
20
20
  /* Simple code for sharing C symbols across different Ruby libraries */
21
21
 
22
22
  #include <ruby.h>
23
- #include <intern.h>
24
23
 
25
24
  #include <namespace.h>
26
25
 
File without changes
File without changes
@@ -84,6 +84,7 @@ module Dobjects
84
84
  'index_col' => false,
85
85
  'headers' => nil, # not used for now.
86
86
  'default' => 0.0/0.0, # defaults to NaN
87
+ 'initial_size' => 5001,
87
88
  'remove_space' => true ,# removes spaces at the beginning of the lines
88
89
  }
89
90
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -21,12 +21,16 @@
21
21
  =end
22
22
 
23
23
  require 'Tioga/FigureConstants.rb'
24
- require 'Tioga/Utils.rb'
24
+ require 'Tioga/Utils'
25
25
 
26
26
  module Tioga
27
27
  class FigureMaker
28
28
 
29
29
  include FigureConstants
30
+
31
+ # For the parsing of Hash arguments
32
+ include HashArguments # For instance methods
33
+ extend HashArguments # For class methods
30
34
 
31
35
  @@default_figure_maker = nil
32
36
  @@which_pdflatex = nil
@@ -34,7 +38,7 @@ class FigureMaker
34
38
 
35
39
  # This URL will contain tioga-(...) when it is exported from the
36
40
  # SVN repository. This is where we'll look for version information.
37
- SVN_URL = '$HeadURL: svn+ssh://rubyforge.org/var/svn/tioga/tags/tioga/Tioga%201.11/split/Tioga/lib/FigMkr.rb $'
41
+ SVN_URL = '$HeadURL$'
38
42
 
39
43
  TIOGA_VERSION = if SVN_URL =~ /tags\/tioga\/Tioga%20([^\/]+)/
40
44
  $1
@@ -1297,7 +1301,12 @@ class FigureMaker
1297
1301
 
1298
1302
  @@keys_for_make_contour = FigureMaker.make_name_lookup_hash([
1299
1303
  'dest_xs', 'dest_ys', 'z_level', 'z', 'level', 'xs', 'ys', 'gaps', 'zs', 'data', 'legit', 'method'])
1304
+
1300
1305
  def make_contour(dict)
1306
+ return FigureMaker.make_contour(dict)
1307
+ end
1308
+
1309
+ def self.make_contour(dict)
1301
1310
  check_dict(dict, @@keys_for_make_contour, 'make_contour')
1302
1311
  z_level = dict['z_level']
1303
1312
  if z_level == nil
@@ -1328,7 +1337,7 @@ class FigureMaker
1328
1337
 
1329
1338
  method = dict['method']
1330
1339
  use_conrec = (method == 'conrec' or method == 'CONREC')? 1 : 0
1331
- pts_array = private_make_contour(gaps, xs, ys, zs, z_level, legit, use_conrec)
1340
+ pts_array = FigureMaker.private_make_contour(gaps, xs, ys, zs, z_level, legit, use_conrec)
1332
1341
 
1333
1342
  unless dest_xs == nil
1334
1343
  dest_xs.resize(pts_array[0].size)
@@ -2516,73 +2525,7 @@ class FigureMaker
2516
2525
  end
2517
2526
  return false
2518
2527
  end
2519
-
2520
- def check_dict(dict,names,str)
2521
- dict.each_key do |name|
2522
- if names[name] == nil
2523
- raise "Sorry: Invalid dictionary key for #{str} (#{name})."
2524
- end
2525
- end
2526
- end
2527
-
2528
- def set_if_given(name, dict)
2529
- val = dict[name]
2530
- return if val == nil
2531
- eval "self." + name + " = val"
2532
- end
2533
-
2534
- def alt_names(dict, name1, name2)
2535
- val = dict[name1]
2536
- val = dict[name2] if val == nil
2537
- return val
2538
- end
2539
-
2540
- def get_if_given_else_use_default_dict(dict, name, default_dict)
2541
- if dict != nil
2542
- val = dict[name]
2543
- return val if val != nil
2544
- end
2545
- val = default_dict[name]
2546
- if val == nil
2547
- raise "Sorry: failed to find value for '#{name}' in the defaults dictionary."
2548
- end
2549
- return val
2550
- end
2551
-
2552
- def get_if_given_else_default(dict, name, default)
2553
- return default if dict == nil
2554
- val = dict[name]
2555
- return val if val != nil
2556
- return default
2557
- end
2558
-
2559
- def complain_if_missing_numeric_arg(dict, name, alt_name, who_called)
2560
- val = dict[name]
2561
- val = dict[alt_name] if val == nil
2562
- if val == nil
2563
- raise "Sorry: Must supply '#{name}' in call to '#{who_called}'"
2564
- end
2565
- if !(val.kind_of?Numeric)
2566
- raise "Sorry: Must supply numeric value for '#{name}' in call to '#{who_called}'"
2567
- end
2568
- return val
2569
- end
2570
-
2571
- def check_pair(ary, name, who_called)
2572
- return false if ary == nil
2573
- if !(ary.kind_of?(Array) || ary.kind_of?(Dvector)) and ary.size == 2
2574
- raise "Sorry: '#{name}' must be array [x,y] for #{who_called}."
2575
- end
2576
- return true
2577
- end
2578
-
2579
- def get_dvec(dict, name, who_called)
2580
- val = dict[name]
2581
- if val == nil || !(val.kind_of? Dvector)
2582
- raise "Sorry: '#{name}' must be a Dvector for '#{who_called}'"
2583
- end
2584
- return val
2585
- end
2528
+
2586
2529
 
2587
2530
  # We make sure that save_dir exists and is a directory, creating it
2588
2531
  # if necessary.
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -82,4 +82,78 @@ module Tioga
82
82
 
83
83
 
84
84
  end
85
+
86
+
87
+ # This module is used internally by Tioga for handling the hash
88
+ # arguments that most of the functions take
89
+ module HashArguments
90
+
91
+ def check_dict(dict,names,str)
92
+ dict.each_key do |name|
93
+ if names[name] == nil
94
+ raise "Sorry: Invalid dictionary key for #{str} (#{name})."
95
+ end
96
+ end
97
+ end
98
+
99
+ def set_if_given(name, dict)
100
+ val = dict[name]
101
+ return if val == nil
102
+ eval "self." + name + " = val"
103
+ end
104
+
105
+ def alt_names(dict, name1, name2)
106
+ val = dict[name1]
107
+ val = dict[name2] if val == nil
108
+ return val
109
+ end
110
+
111
+ def get_if_given_else_use_default_dict(dict, name, default_dict)
112
+ if dict != nil
113
+ val = dict[name]
114
+ return val if val != nil
115
+ end
116
+ val = default_dict[name]
117
+ if val == nil
118
+ raise "Sorry: failed to find value for '#{name}' in the defaults dictionary."
119
+ end
120
+ return val
121
+ end
122
+
123
+ def get_if_given_else_default(dict, name, default)
124
+ return default if dict == nil
125
+ val = dict[name]
126
+ return val if val != nil
127
+ return default
128
+ end
129
+
130
+ def complain_if_missing_numeric_arg(dict, name, alt_name, who_called)
131
+ val = dict[name]
132
+ val = dict[alt_name] if val == nil
133
+ if val == nil
134
+ raise "Sorry: Must supply '#{name}' in call to '#{who_called}'"
135
+ end
136
+ if !(val.kind_of?Numeric)
137
+ raise "Sorry: Must supply numeric value for '#{name}' in call to '#{who_called}'"
138
+ end
139
+ return val
140
+ end
141
+
142
+ def check_pair(ary, name, who_called)
143
+ return false if ary == nil
144
+ if !(ary.kind_of?(Array) || ary.kind_of?(Dobjects::Dvector)) and ary.size == 2
145
+ raise "Sorry: '#{name}' must be array [x,y] for #{who_called}."
146
+ end
147
+ return true
148
+ end
149
+
150
+ def get_dvec(dict, name, who_called)
151
+ val = dict[name]
152
+ if val == nil || !(val.kind_of? Dobjects::Dvector)
153
+ raise "Sorry: '#{name}' must be a Dvector for '#{who_called}'"
154
+ end
155
+ return val
156
+ end
157
+
158
+ end
85
159
  end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
data/tests/Icon_Test.pdf CHANGED
Binary file
@@ -1,5 +1,7 @@
1
1
  # A small benchmarking file for fancy_read and fast_fancy_read, just to make
2
2
  # sure the latter deserves its name ;-)...
3
+ #
4
+ # Now the comparison between fancy_read and fast_fancy_read
3
5
 
4
6
  require 'Dobjects/Dvector'
5
7
  require 'benchmark'
@@ -15,55 +17,41 @@ Benchmark.bm do |x|
15
17
  end
16
18
  f.close
17
19
  end
18
- x.report("fancy_read(100000):") do
20
+ x.report("fancy_read(100 000):") do
19
21
  stream = File.open(f.path)
20
22
  Dobjects::Dvector.fancy_read(stream, nil, 'default'=> 0.0).size
21
23
  end
22
- x.report("fancy_read(100000, 2nd):") do
24
+ x.report("fancy_read(100 000), 2nd time:") do
23
25
  stream = File.open(f.path)
24
26
  Dobjects::Dvector.fancy_read(stream, nil, 'default'=> 0.0).size
25
27
  end
26
- x.report("fast_fancy_read(100000):") do
28
+
29
+ # Trying pre-allocation.
30
+ x.report("fancy_read(100 000), preallocation to 1 :") do
31
+ stream = File.open(f.path)
32
+ Dobjects::Dvector.fancy_read(stream, nil, 'default'=> 0.0,
33
+ 'initial_size' => 1).size
34
+ end
35
+ x.report("fancy_read(100 000), preallocation to 49999 :") do
27
36
  stream = File.open(f.path)
28
- Dobjects::Dvector.fast_fancy_read(stream, {
29
- 'sep' => /\s+/,
30
- 'comments' => /^\s*\#/,
31
- 'skip_first' => 0,
32
- 'index_col' => false,
33
- 'remove_space' => true,
34
- 'default'=> 0.0}).size
37
+ Dobjects::Dvector.fancy_read(stream, nil, 'default'=> 0.0,
38
+ 'initial_size' => 49999).size
35
39
  end
36
- x.report("fast_fancy_read(100000, 2nd):") do
40
+ x.report("fancy_read(100 000), preallocation to 100 000 :") do
37
41
  stream = File.open(f.path)
38
- Dobjects::Dvector.fast_fancy_read(stream, {
39
- 'sep' => /\s+/,
40
- 'comments' => /^\s*\#/,
41
- 'skip_first' => 0,
42
- 'index_col' => false,
43
- 'remove_space' => true,
44
- 'default'=> 0.0}).size
42
+ Dobjects::Dvector.fancy_read(stream, nil, 'default'=> 0.0,
43
+ 'initial_size' => 100000).size
45
44
  end
45
+
46
46
  # We create a smaller file:
47
47
  f = Tempfile.new("data")
48
48
  1000.times do |i|
49
49
  f.puts "#{i*1.0}\t#{i**1.3}\t#{i**0.7}"
50
50
  end
51
51
  f.close
52
- x.report("fast_fancy_read(100 * 1000):") do
53
- stream = File.open(f.path)
54
- 100.times do
55
- Dobjects::Dvector.fast_fancy_read(stream, {
56
- 'sep' => /\s+/,
57
- 'comments' => /^\s*\#/,
58
- 'skip_first' => 0,
59
- 'index_col' => false,
60
- 'remove_space' => true,
61
- 'default'=> 0.0})
62
- end
63
- end
64
52
  x.report("fancy_read(100 * 1000):") do
65
- stream = File.open(f.path)
66
53
  100.times do
54
+ stream = File.open(f.path)
67
55
  Dobjects::Dvector.fancy_read(stream, nil, 'default'=> 0.0)
68
56
  end
69
57
  end
@@ -72,23 +60,13 @@ Benchmark.bm do |x|
72
60
  string = ""
73
61
  x.report("string creation:") do
74
62
  50000.times do |i|
75
- string += "#{i*1.0}\t#{i**1.3}\t#{i**0.7}\n"
63
+ string.concat("#{i*1.0}\t#{i**1.3}\t#{i**0.7}\n")
76
64
  end
77
65
  end
78
66
  x.report("fancy_read(50000):") do
79
67
  stream = StringIO.new(string)
80
68
  Dobjects::Dvector.fancy_read(stream, nil, 'default'=> 0.0).size
81
69
  end
82
- x.report("fast_fancy_read(50000):") do
83
- stream = StringIO.new(string)
84
- Dobjects::Dvector.fast_fancy_read(stream, {
85
- 'sep' => /\s+/,
86
- 'comments' => /^\s*\#/,
87
- 'skip_first' => 0,
88
- 'index_col' => false,
89
- 'remove_space' => true,
90
- 'default'=> 0.0}).size
91
- end
92
70
 
93
71
  end
94
72