facets 2.2.1 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (313) hide show
  1. data/CHANGES +6 -0
  2. data/NOTES +14 -1
  3. data/Rakefile +26 -0
  4. data/demo/bench/general/bench_calls.rb +74 -0
  5. data/demo/bench/general/bench_includes.rb +25 -0
  6. data/demo/bench/general/bench_methods.rb +17 -0
  7. data/demo/bench/general/bench_pathname.rb +24 -0
  8. data/demo/bench/general/bench_range.rb +64 -0
  9. data/demo/bench/general/bench_return.rb +56 -0
  10. data/demo/bench/general/bench_yeild.rb +75 -0
  11. data/lib/{more → class}/facets/association.rb +0 -0
  12. data/lib/{more → class}/facets/autoarray.rb +0 -0
  13. data/lib/{more → class}/facets/basicobject.rb +0 -0
  14. data/lib/{more → class}/facets/buildingblock.rb +0 -44
  15. data/lib/{more → class}/facets/cachedelegator.rb +3 -0
  16. data/lib/{more → class}/facets/coroutine.rb +0 -56
  17. data/lib/{more → class}/facets/dictionary.rb +0 -0
  18. data/lib/{more → class}/facets/downloader.rb +0 -0
  19. data/lib/{more → class}/facets/filelist.rb +0 -0
  20. data/lib/{more → class}/facets/fileshell.rb +0 -0
  21. data/lib/{more → class}/facets/hashbuilder.rb +0 -0
  22. data/lib/{more → class}/facets/heap.rb +0 -0
  23. data/lib/{more → class}/facets/infinity.rb +0 -46
  24. data/lib/{more → class}/facets/interval.rb +0 -0
  25. data/lib/{more → class}/facets/ioredirect.rb +0 -0
  26. data/lib/{more → class}/facets/linkedlist.rb +0 -42
  27. data/lib/{more → class}/facets/lrucache.rb +0 -23
  28. data/lib/{more → class}/facets/minitar.rb +0 -0
  29. data/lib/{more → class}/facets/nackclass.rb +0 -0
  30. data/lib/{more → class}/facets/nullclass.rb +0 -0
  31. data/lib/{more → class}/facets/opencascade.rb +0 -70
  32. data/lib/{more → class}/facets/opencollection.rb +0 -0
  33. data/lib/class/facets/openhash.rb +41 -0
  34. data/lib/{more → class}/facets/openobject.rb +0 -121
  35. data/lib/{more → class}/facets/orderedhash.rb +0 -0
  36. data/lib/{more → class}/facets/pathlist.rb +0 -0
  37. data/lib/{more → class}/facets/pool.rb +0 -0
  38. data/lib/{more → class}/facets/pqueue.rb +0 -0
  39. data/lib/{more → class}/facets/progressbar.rb +0 -0
  40. data/lib/{more → class}/facets/recorder.rb +0 -40
  41. data/lib/{more → class}/facets/reference.rb +0 -0
  42. data/lib/{more → class}/facets/rwdelegator.rb +0 -0
  43. data/lib/{more → class}/facets/semaphore.rb +0 -0
  44. data/lib/{more → class}/facets/syncarray.rb +0 -24
  45. data/lib/{more → class}/facets/synchash.rb +1 -25
  46. data/lib/{more → class}/facets/timer.rb +0 -62
  47. data/lib/{more → class}/facets/tuple.rb +0 -60
  48. data/lib/{more → class}/facets/version.rb +0 -0
  49. data/lib/core/facets/dir/multiglob.rb +20 -5
  50. data/lib/core/facets/enumerable/cartesian.rb +2 -2
  51. data/lib/core/facets/enumerable/combination.rb +9 -1
  52. data/lib/core/facets/kernel/object.rb +1 -1
  53. data/lib/{more → mixin}/facets/binreadable.rb +0 -62
  54. data/lib/{more → mixin}/facets/buildable.rb +0 -48
  55. data/lib/mixin/facets/cloneable.rb +90 -0
  56. data/lib/{more → mixin}/facets/enumerablepass.rb +0 -81
  57. data/lib/{more → mixin}/facets/expirable.rb +0 -0
  58. data/lib/{more → mixin}/facets/fileable.rb +0 -0
  59. data/lib/{more → mixin}/facets/instantiable.rb +0 -30
  60. data/lib/{more → mixin}/facets/multiton.rb +0 -0
  61. data/lib/{more → mixin}/facets/registerable.rb +0 -0
  62. data/lib/mixin/facets/tasksystem.rb +350 -0
  63. data/lib/{more → mixin}/facets/uninheritable.rb +1 -39
  64. data/lib/{more → mixin}/facets/validation.rb +0 -0
  65. data/lib/more/facets/arguments.rb +0 -66
  66. data/lib/more/facets/attributes.rb +0 -35
  67. data/lib/more/facets/bbcode.rb +1 -31
  68. data/lib/more/facets/bytes.rb +0 -80
  69. data/lib/more/facets/class_extension.rb +0 -66
  70. data/lib/more/facets/classmethods.rb +0 -64
  71. data/lib/more/facets/compare_on.rb +0 -52
  72. data/lib/more/facets/curry.rb +0 -29
  73. data/lib/more/facets/cut.rb +0 -27
  74. data/lib/more/facets/date.rb +0 -54
  75. data/lib/more/facets/dependency.rb +0 -70
  76. data/lib/more/facets/elementor.rb +0 -67
  77. data/lib/more/facets/getoptlong.rb +0 -30
  78. data/lib/more/facets/{hash_keyize.rb → hash/keyize.rb} +0 -0
  79. data/lib/more/facets/inheritor.rb +0 -150
  80. data/lib/more/facets/instantise.rb +0 -41
  81. data/lib/more/facets/let.rb +0 -20
  82. data/lib/more/facets/memoize.rb +0 -45
  83. data/lib/more/facets/multipliers.rb +0 -110
  84. data/lib/more/facets/ostruct.rb +0 -124
  85. data/lib/more/facets/random.rb +0 -153
  86. data/lib/more/facets/rbconfig.rb +55 -0
  87. data/lib/more/facets/set.rb +27 -0
  88. data/lib/more/facets/snapshot.rb +0 -30
  89. data/lib/more/facets/stylize.rb +0 -147
  90. data/lib/more/facets/times.rb +0 -98
  91. data/lib/more/facets/tracepoint.rb +194 -0
  92. data/lib/more/facets/typecast.rb +0 -63
  93. data/lib/more/facets/ziputils.rb +7 -0
  94. data/log/Changelog-0.txt +239 -0
  95. data/log/Changelog-1.txt +450 -0
  96. data/log/Changelog.txt +841 -0
  97. data/log/Fixme.txt +18 -0
  98. data/log/Testlog.txt +188 -0
  99. data/log/Todo.txt +326 -0
  100. data/meta/MANIFEST +1 -1
  101. data/meta/VERSION +1 -0
  102. data/meta/authors +48 -0
  103. data/meta/description +8 -0
  104. data/meta/project.yaml +11 -5
  105. data/task/install +4 -2
  106. data/task/rdoc +5 -0
  107. data/task/test +40 -0
  108. data/test/{unit → class}/test_association.rb +0 -0
  109. data/test/{unit → class}/test_autoarray.rb +0 -0
  110. data/test/{unit → class}/test_basicobject.rb +0 -0
  111. data/test/{unit → class}/test_buildingblock.rb +1 -0
  112. data/test/{unit → class}/test_coroutine.rb +0 -0
  113. data/test/{unit → class}/test_dictionary.rb +0 -0
  114. data/test/{unit → class}/test_infinity.rb +0 -0
  115. data/test/{unit → class}/test_interval.rb +0 -0
  116. data/test/{unit → class}/test_linkedlist.rb +1 -1
  117. data/test/{unit → class}/test_lrucache.rb +3 -0
  118. data/test/{unit → class}/test_opencascade.rb +0 -0
  119. data/test/{unit → class}/test_openobject.rb +0 -0
  120. data/test/{unit → class}/test_recorder.rb +0 -1
  121. data/test/{unit → class}/test_syncarray.rb +2 -4
  122. data/test/{unit → class}/test_synchash.rb +2 -4
  123. data/test/{unit → class}/test_timer.rb +0 -1
  124. data/test/{unit → class}/test_tuple.rb +0 -0
  125. data/test/{unit → core}/array/test_delete.rb +0 -0
  126. data/test/{unit → core}/array/test_indexable.rb +0 -0
  127. data/test/{unit → core}/array/test_merge.rb +0 -0
  128. data/test/{unit → core}/array/test_only.rb +0 -0
  129. data/test/{unit → core}/array/test_pad.rb +0 -0
  130. data/test/{unit → core}/array/test_rotate.rb +0 -0
  131. data/test/{unit → core}/array/test_select.rb +0 -0
  132. data/test/{unit → core}/array/test_stackable.rb +0 -0
  133. data/test/{unit/binding/test_cflow.rb → core/binding/test_caller.rb} +2 -2
  134. data/test/{unit → core}/binding/test_defined.rb +0 -0
  135. data/test/{unit → core}/binding/test_eval.rb +0 -0
  136. data/test/{unit → core}/binding/test_here.rb +0 -0
  137. data/test/{unit → core}/binding/test_self.rb +0 -0
  138. data/test/{unit → core}/binding/test_vars.rb +0 -0
  139. data/test/{unit → core}/class/test_descendents.rb +0 -0
  140. data/test/{unit → core}/class/test_initializer.rb +0 -0
  141. data/test/{unit → core}/class/test_remove_descendents.rb +0 -0
  142. data/test/{unit → core}/comparable/test_bound.rb +0 -0
  143. data/test/{unit → core}/comparable/test_cmp.rb +0 -0
  144. data/test/{unit → core}/dir/test_parent.rb +0 -0
  145. data/test/{unit → core}/dir/test_recurse.rb +0 -0
  146. data/test/{unit → core}/dir/test_traverse.rb +0 -0
  147. data/test/{unit → core}/enumerable/test_cartesian.rb +0 -0
  148. data/test/{unit → core}/enumerable/test_collect.rb +0 -0
  149. data/test/{unit → core}/enumerable/test_combination.rb +0 -0
  150. data/test/{unit → core}/enumerable/test_count.rb +0 -0
  151. data/test/{unit → core}/enumerable/test_each.rb +0 -0
  152. data/test/{unit → core}/enumerable/test_mash.rb +0 -0
  153. data/test/{unit → core}/enumerable/test_permutation.rb +0 -0
  154. data/test/{unit → core}/enumerable/test_probability.rb +0 -0
  155. data/test/{unit → core}/enumerable/test_split.rb +0 -0
  156. data/test/{unit → core}/exception/test_detail.rb +0 -0
  157. data/test/{unit → core}/file/test_null.rb +0 -0
  158. data/test/{unit → core}/file/test_read.rb +0 -0
  159. data/test/{unit → core}/file/test_sanitize.rb +0 -0
  160. data/test/{unit → core}/file/test_split_all.rb +0 -0
  161. data/test/{unit → core}/file/test_write.rb +0 -0
  162. data/test/{unit → core}/filetest/test_root.rb +0 -0
  163. data/test/{unit → core}/hash/test_alias.rb +0 -0
  164. data/test/{unit → core}/hash/test_at.rb +0 -0
  165. data/test/{unit → core}/hash/test_autonew.rb +0 -0
  166. data/test/core/hash/test_collate.rb +33 -0
  167. data/test/{unit → core}/hash/test_delete.rb +0 -0
  168. data/test/{unit → core}/hash/test_each_with_key.rb +0 -0
  169. data/test/{unit → core}/hash/test_has_keys.rb +0 -0
  170. data/test/{unit → core}/hash/test_insert.rb +0 -0
  171. data/test/{unit → core}/hash/test_inverse.rb +0 -0
  172. data/test/{unit → core}/hash/test_op.rb +0 -0
  173. data/test/{unit → core}/hash/test_rekey.rb +0 -0
  174. data/test/{unit → core}/hash/test_reverse_merge.rb +0 -0
  175. data/test/{unit → core}/hash/test_select.rb +0 -0
  176. data/test/{unit → core}/hash/test_swap.rb +0 -0
  177. data/test/{unit → core}/hash/test_traverse.rb +0 -0
  178. data/test/{unit → core}/hash/test_update.rb +0 -0
  179. data/test/{unit → core}/hash/test_weave.rb +0 -0
  180. data/test/{unit → core}/hash/test_zipnew.rb +0 -0
  181. data/test/{unit → core}/integer/test_bitmask.rb +0 -0
  182. data/test/{unit → core}/integer/test_factorial.rb +0 -0
  183. data/test/{unit → core}/integer/test_multiple.rb +0 -0
  184. data/test/{unit → core}/integer/test_of.rb +0 -0
  185. data/test/{unit → core}/kernel/test_callstack.rb +0 -0
  186. data/test/{unit → core}/kernel/test_constant.rb +0 -0
  187. data/test/{unit → core}/kernel/test_deepcopy.rb +0 -0
  188. data/test/{unit → core}/kernel/test_instance.rb +0 -0
  189. data/test/{unit → core}/kernel/test_metaid.rb +0 -0
  190. data/test/{unit → core}/kernel/test_object.rb +1 -1
  191. data/test/{unit → core}/kernel/test_populate.rb +0 -0
  192. data/test/{unit → core}/kernel/test_report.rb +0 -0
  193. data/test/{unit → core}/kernel/test_returning.rb +0 -0
  194. data/test/{unit → core}/kernel/test_silence.rb +0 -0
  195. data/test/{unit → core}/kernel/test_super.rb +0 -0
  196. data/test/{unit → core}/kernel/test_tap.rb +0 -0
  197. data/test/{unit → core}/kernel/test_val.rb +0 -0
  198. data/test/{unit → core}/kernel/test_withattr.rb +0 -0
  199. data/test/{unit → core}/matchdata/test_match.rb +0 -0
  200. data/test/{unit → core}/matchdata/test_matchset.rb +0 -0
  201. data/test/{unit → core}/module/test_abstract.rb +0 -0
  202. data/test/{unit → core}/module/test_alias.rb +0 -0
  203. data/test/{unit → core}/module/test_cattr.rb +0 -0
  204. data/test/{unit → core}/module/test_clone.rb +0 -0
  205. data/test/{unit → core}/module/test_include.rb +0 -0
  206. data/test/{unit → core}/module/test_modify.rb +0 -0
  207. data/test/{unit → core}/module/test_name.rb +0 -0
  208. data/test/{unit → core}/module/test_traits.rb +0 -0
  209. data/test/{unit → core}/numeric/test_round.rb +0 -0
  210. data/test/{unit → core}/proc/test_bind.rb +0 -0
  211. data/test/{unit → core}/proc/test_compose.rb +0 -0
  212. data/test/{unit → core}/range/test_combine.rb +0 -0
  213. data/test/{unit → core}/range/test_overlap.rb +0 -0
  214. data/test/{unit → core}/regexp/test_arity.rb +0 -0
  215. data/test/{unit → core}/string/test_align.rb +0 -0
  216. data/test/{unit → core}/string/test_blank.rb +0 -0
  217. data/test/{unit → core}/string/test_bracket.rb +0 -0
  218. data/test/{unit → core}/string/test_case.rb +0 -0
  219. data/test/{unit → core}/string/test_crypt.rb +0 -0
  220. data/test/{unit → core}/string/test_filter.rb +0 -0
  221. data/test/{unit → core}/string/test_indexable.rb +0 -0
  222. data/test/{unit → core}/string/test_interpolate.rb +0 -0
  223. data/test/{unit → core}/string/test_natcmp.rb +0 -0
  224. data/test/{unit → core}/string/test_nchar.rb +0 -0
  225. data/test/{unit → core}/string/test_op.rb +0 -0
  226. data/test/{unit → core}/string/test_partitions.rb +0 -0
  227. data/test/{unit → core}/string/test_range.rb +0 -0
  228. data/test/{unit → core}/string/test_regesc.rb +0 -0
  229. data/test/{unit → core}/string/test_scan.rb +0 -0
  230. data/test/{unit → core}/string/test_stackable.rb +0 -0
  231. data/test/{unit → core}/string/test_tabs.rb +0 -0
  232. data/test/{unit → core}/string/test_wrap.rb +0 -0
  233. data/test/{unit → core}/symbol/test_chomp.rb +0 -0
  234. data/test/{unit → core}/symbol/test_generate.rb +0 -0
  235. data/test/{unit → core}/symbol/test_not.rb +0 -0
  236. data/test/{unit → core}/symbol/test_shadow.rb +0 -0
  237. data/test/{unit → core}/symbol/test_succ.rb +0 -0
  238. data/test/{unit → core}/symbol/test_to_proc.rb +0 -0
  239. data/test/{unit → core}/test_1stclassmethod.rb +0 -0
  240. data/test/{unit → core}/test_boolean.rb +0 -0
  241. data/test/{unit → core}/test_conversion.rb +0 -0
  242. data/test/{unit → core}/test_functor.rb +0 -0
  243. data/test/{unit → core}/time/test_change.rb +0 -0
  244. data/test/{unit → core}/time/test_elapse.rb +0 -0
  245. data/test/{unit → core}/time/test_stamp.rb +0 -0
  246. data/test/{unit → mixin}/test_binreadable.rb +0 -0
  247. data/test/{unit → mixin}/test_buildable.rb +1 -0
  248. data/test/mixin/test_cloneable.rb +41 -0
  249. data/test/{unit → mixin}/test_enumerablepass.rb +0 -0
  250. data/test/{unit → mixin}/test_instantiable.rb +2 -1
  251. data/test/{unit → mixin}/test_multiton.rb +0 -0
  252. data/test/{unit → mixin}/test_uninheritable.rb +1 -2
  253. data/test/{unit → more/hash}/test_keyize.rb +1 -1
  254. data/test/{unit → more}/test_advice.rb +0 -0
  255. data/test/{unit → more}/test_annotations.rb +0 -0
  256. data/test/{unit → more}/test_ansicode.rb +0 -0
  257. data/test/{unit → more}/test_aop.rb +0 -0
  258. data/test/{unit → more}/test_arguments.rb +1 -0
  259. data/test/{unit → more}/test_attributes.rb +2 -2
  260. data/test/{unit → more}/test_bbcode.rb +1 -0
  261. data/test/{unit → more}/test_bytes.rb +1 -0
  262. data/test/{unit → more}/test_class_extension.rb +2 -1
  263. data/test/{unit → more}/test_classmethods.rb +2 -1
  264. data/test/{unit → more}/test_compare_on.rb +0 -1
  265. data/test/{unit → more}/test_continuation.rb +0 -0
  266. data/test/{unit → more}/test_crypt.rb +0 -0
  267. data/test/{unit → more}/test_curry.rb +1 -0
  268. data/test/{unit → more}/test_cut.rb +2 -1
  269. data/test/{unit → more}/test_date.rb +1 -1
  270. data/test/{unit → more}/test_dependency.rb +2 -2
  271. data/test/{unit → more}/test_elementor.rb +1 -1
  272. data/test/{unit → more}/test_getoptlong.rb +1 -0
  273. data/test/{unit → more}/test_inheritor.rb +1 -1
  274. data/test/{unit → more}/test_instantise.rb +2 -1
  275. data/test/{unit → more}/test_interface.rb +0 -0
  276. data/test/{unit → more}/test_let.rb +0 -1
  277. data/test/{unit → more}/test_memoize.rb +2 -3
  278. data/test/{unit → more}/test_multipliers.rb +1 -1
  279. data/test/{unit → more}/test_namespace.rb +0 -0
  280. data/test/{unit → more}/test_ostruct.rb +0 -0
  281. data/test/{unit → more}/test_overload.rb +0 -0
  282. data/test/{unit → more}/test_paramix.rb +0 -0
  283. data/test/{unit → more}/test_prototype.rb +0 -0
  284. data/test/more/test_random.rb +146 -0
  285. data/test/{unit → more}/test_snapshot.rb +0 -3
  286. data/test/{unit → more}/test_stylize.rb +1 -2
  287. data/test/{unit → more}/test_thread.rb +0 -0
  288. data/test/{unit → more}/test_times.rb +2 -2
  289. data/test/{unit → more}/test_typecast.rb +0 -3
  290. metadata +1117 -1098
  291. data/lib/more/facets/cloneable.rb +0 -75
  292. data/log/changelog.txt +0 -0
  293. data/meta/facets.roll +0 -4
  294. data/meta/google_ad.html +0 -15
  295. data/meta/icli.yaml +0 -17
  296. data/task/changes +0 -29
  297. data/task/clean +0 -17
  298. data/task/clobber/package +0 -10
  299. data/task/log +0 -17
  300. data/task/prepare +0 -7
  301. data/task/publish +0 -43
  302. data/task/release +0 -10
  303. data/task/stamp +0 -33
  304. data/task/stats +0 -138
  305. data/task/test/cross +0 -309
  306. data/task/test/each +0 -42
  307. data/task/test/load +0 -30
  308. data/task/test/pairs +0 -50
  309. data/task/test/solo +0 -294
  310. data/task/test/syntax +0 -31
  311. data/task/test/whole +0 -34
  312. data/test/unit/hash/test_collate.rb +0 -31
  313. data/test/unit/test_random.rb +0 -149
data/CHANGES CHANGED
@@ -1,5 +1,11 @@
1
1
  = Facets Change History
2
2
 
3
+ == 2.3.0 /
4
+
5
+ * Reorganized library into four groups: core, more, class and mixin.
6
+ * Added tracepoint.rb back to the library.
7
+ * Fixed multiglob_r bug, so it will NOT follow symlinks.
8
+
3
9
  == 2.2.1 / 2007-12-22
4
10
 
5
11
  * Got rid of methods subdir. All method redirects are in core/.
data/NOTES CHANGED
@@ -1,4 +1,17 @@
1
- Facets 2.2.1 has been released.
1
+ Facets 2.3.0 has been released.
2
+
3
+ Facets 2.3 makes some nice internal reorganization, rather
4
+ then just the split between core/ and more/, we have added
5
+ class/ and mixin/. This helps a great deal in working
6
+ with the library. If does not effect the end-user in anyway
7
+ however --even so we felt it enough to warrent a minor
8
+ version bump rather than just a tiny.
9
+
10
+ Amoung other changes with this release, cloneable.rb is
11
+ now a true deep dup/clone mixin; tracepoint.rb returns
12
+ to the library; and ...
13
+
14
+ As of 2.2.1:
2
15
 
3
16
  This release get rid of the underlying methods subdir.
4
17
  All method redirects are now in core, to ensure
@@ -0,0 +1,26 @@
1
+ # Facets Rakefile
2
+
3
+
4
+ task :default => [:test]
5
+
6
+
7
+ desc "Download docs package."
8
+
9
+ task :rdoc do
10
+ system 'task/rdoc'
11
+ end
12
+
13
+
14
+ desc "Run unit tests (default)."
15
+
16
+ task :test do
17
+ system 'task/test'
18
+ end
19
+
20
+
21
+ desc "Local site_ruby install."
22
+
23
+ task :install do
24
+ system 'task/install'
25
+ end
26
+
@@ -0,0 +1,74 @@
1
+ =begin
2
+
3
+ Some speed comparisions between ways to call a method.
4
+
5
+ =end
6
+
7
+ require 'benchmark'
8
+
9
+ $n = 50000
10
+
11
+ # standard array
12
+
13
+ def callme ; 1 ; end
14
+
15
+ $m = self.class.instance_method(:callme)
16
+
17
+
18
+ def call_normal
19
+ $n.times do
20
+ callme
21
+ end
22
+ end
23
+
24
+ def call_by_send_symbol
25
+ $n.times do
26
+ send(:callme)
27
+ end
28
+ end
29
+
30
+ def call_by_send_string
31
+ $n.times do
32
+ send("callme")
33
+ end
34
+ end
35
+
36
+ def call_by_eval
37
+ $n.times do
38
+ eval "callme"
39
+ end
40
+ end
41
+
42
+ def call_by_instance_eval
43
+ $n.times do
44
+ instance_eval { callme }
45
+ end
46
+ end
47
+
48
+ def call_by_bind
49
+ $n.times do
50
+ $m.bind(self).call
51
+ end
52
+ end
53
+
54
+ def call_inst_eval_send
55
+ $n.times do
56
+ $m.instance_eval { send(:callme) }
57
+ end
58
+ end
59
+
60
+ ### --- bench ---
61
+
62
+ puts "\nCURRENT"
63
+ Benchmark.bm(15) do |b|
64
+ b.report("normal :") { call_normal }
65
+ b.report("send_symbol :") { call_by_send_symbol }
66
+ b.report("send_string :") { call_by_send_string }
67
+ b.report("bind :") { call_by_bind }
68
+ b.report("instance_eval :") { call_by_instance_eval }
69
+ b.report("by_eval :") { call_by_eval }
70
+ b.report("inst_eval_send :") { call_inst_eval_send }
71
+ end
72
+
73
+
74
+
@@ -0,0 +1,25 @@
1
+
2
+ $n = 100
3
+
4
+ puts "Generating #{$n} cascading modules..."
5
+
6
+ $m = []
7
+ (1..$n).each { |i|
8
+ $m[i] = Module.new
9
+ $m[i].class_eval {
10
+ define_method( "_#{i}" ) { puts "Called method in module #{i}." }
11
+ include $m[i-1] if $m[i-1]
12
+ }
13
+ }
14
+
15
+ class ManyIncludes
16
+ include $m[$n]
17
+ end
18
+
19
+ mm = ManyIncludes.new
20
+ mn = "_#{$n/2}"
21
+
22
+ t0 = Time.now
23
+ mm.send(mn)
24
+ t1 = Time.now
25
+ puts "Time to call a single method among #{$n} modules: #{(t1 - t0).to_f} seconds."
@@ -0,0 +1,17 @@
1
+
2
+ class ManyMethods
3
+
4
+ puts "Generating methods..."
5
+
6
+ (0..100000).each do |i|
7
+ define_method( "_#{i}" ) { puts "Called method #{i}." }
8
+ end
9
+
10
+ end
11
+
12
+ mm = ManyMethods.new
13
+
14
+ n1 = Time.now
15
+ mm._50000
16
+ n2 = Time.now
17
+ puts "Time to call a single method among 100000: #{(n2 - n1).to_f} seconds."
@@ -0,0 +1,24 @@
1
+
2
+ require 'benchmark'
3
+ #require 'pathname'
4
+ require 'mega/pathname'
5
+
6
+ $f1 = "a/b/c"
7
+ $f2 = "d/e/f"
8
+
9
+ $p1 = Pathname.new($f1)
10
+ $p2 = Pathname.new($f2)
11
+
12
+ def file_join
13
+ File.join( $f1 , $f2 )
14
+ end
15
+
16
+ def path_join
17
+ $p1 + $p2
18
+ end
19
+
20
+ n = 50000
21
+ Benchmark.bm(7) do |x|
22
+ x.report("path-join") { n.times do ; path_join ; end }
23
+ x.report("file-join") { n.times do ; file_join ; end }
24
+ end
@@ -0,0 +1,64 @@
1
+
2
+ require 'benchmark'
3
+
4
+ # member?
5
+
6
+ $n = 50000
7
+
8
+ def range_nan
9
+ $n.times { ('a'..'k').member?('f') }
10
+ $n.times { ('a'..'k').member?('r') }
11
+ end
12
+
13
+ def range_small
14
+ $n.times { (0..6).member?(3) }
15
+ $n.times { (0..6).member?(7) }
16
+ end
17
+
18
+ def range_med
19
+ $n.times { (0..1000).member?(500) }
20
+ $n.times { (0..1000).member?(1001) }
21
+ end
22
+
23
+ # index
24
+
25
+ $a = [ 'x' ] * 100
26
+ $m = 500000
27
+
28
+ def range_index
29
+ i = 1
30
+ $m.times { $a[1..i]; i += 1 }
31
+ end
32
+
33
+ def length_index
34
+ i = 1
35
+ $m.times { $a[1,i]; i += 1 }
36
+ end
37
+
38
+ ### --- bench ---
39
+
40
+ puts "\nINDEXING"
41
+ Benchmark.bm(15) do |b|
42
+ b.report("range_index:") { range_index }
43
+ b.report("length_index:") { length_index }
44
+ end
45
+
46
+ puts "\n\nNew vs. Old\n"
47
+
48
+ puts "\nCURRENT"
49
+ Benchmark.bm(15) do |b|
50
+ b.report("range_nan:") { range_nan }
51
+ b.report("range_samll:") { range_small }
52
+ b.report("range_med:") { range_med }
53
+ end
54
+
55
+ puts "\nNEW"
56
+ require 'trix-dev/range/range'
57
+ Benchmark.bm(15) do |b|
58
+ b.report("range_nan:") { range_nan }
59
+ b.report("range_samll:") { range_small }
60
+ b.report("range_med:") { range_med }
61
+ end
62
+
63
+ puts
64
+
@@ -0,0 +1,56 @@
1
+
2
+ require 'benchmark'
3
+
4
+ class Ret
5
+ def initialize(a,b,c,d,e)
6
+ @a = a
7
+ @b = b
8
+ @c = c
9
+ @d = d
10
+ @e = e
11
+ end
12
+ end
13
+
14
+ @preobj = Object.new
15
+ def @preobj.assign(a,b,c,d,e)
16
+ @a = a
17
+ @b = b
18
+ @c = c
19
+ @d = d
20
+ @e = e
21
+ end
22
+
23
+ def return_list
24
+ return 1, 2, 3, 4, 5
25
+ end
26
+
27
+ def return_array
28
+ return [1, 2, 3, 4, 5]
29
+ end
30
+
31
+ def return_hash
32
+ return { 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5 }
33
+ end
34
+
35
+ def return_object
36
+ return Ret.new(1, 2, 3, 4, 5)
37
+ end
38
+
39
+ def return_preobj
40
+ return @preobj.assign(1, 2, 3, 4, 5)
41
+ end
42
+
43
+ def return_globals
44
+ $a = 1; $b = 2; $c = 3; $d = 4; $e = 5
45
+ end
46
+
47
+ n = 50000
48
+ Benchmark.bm(7) do |x|
49
+ x.report("global") { n.times do ; return_globals ; end }
50
+ x.report("preobj") { n.times do ; return_preobj ; end }
51
+ x.report("object") { n.times do ; return_object ; end }
52
+ x.report("array:") { n.times do ; return_array ; end }
53
+ x.report("hash:") { n.times do ; return_hash ; end }
54
+ x.report("list:") { n.times do ; return_list ; end }
55
+ end
56
+
@@ -0,0 +1,75 @@
1
+ =begin
2
+
3
+ Some speed comparisions between yield vs. block.
4
+
5
+ =end
6
+
7
+ require 'benchmark'
8
+
9
+ $n = 10000
10
+ $b = proc { 1 }
11
+
12
+ # standard array
13
+
14
+ def with_yield
15
+ yield
16
+ end
17
+
18
+ def with_block( &yld )
19
+ yld.call
20
+ end
21
+
22
+ def with_bracket( &yld )
23
+ yld[]
24
+ end
25
+
26
+ # bench calls
27
+
28
+ def call_with_yield
29
+ $n.times do
30
+ with_yield { 1 }
31
+ end
32
+ end
33
+
34
+ def call_with_yield_on_proc
35
+ $n.times do
36
+ with_yield &$b
37
+ end
38
+ end
39
+
40
+ def call_with_block
41
+ $n.times do
42
+ with_block { 1 }
43
+ end
44
+ end
45
+
46
+ def call_with_block_on_proc
47
+ $n.times do
48
+ with_block &$b
49
+ end
50
+ end
51
+
52
+ def call_with_bracket
53
+ $n.times do
54
+ with_bracket { 1 }
55
+ end
56
+ end
57
+
58
+ def call_with_bracket_on_proc
59
+ $n.times do
60
+ with_bracket &$b
61
+ end
62
+ end
63
+
64
+ ### --- bench ---
65
+
66
+ puts "\nYield vs. Block"
67
+ Benchmark.bm(15) do |b|
68
+ b.report("block :") { call_with_block }
69
+ b.report("block a proc :") { call_with_block_on_proc }
70
+ b.report("bracket :") { call_with_bracket }
71
+ b.report("bracket a proc :") { call_with_bracket_on_proc }
72
+ b.report("yield :") { call_with_yield }
73
+ b.report("yield a proc :") { call_with_yield_on_proc }
74
+ end
75
+
File without changes
@@ -217,47 +217,3 @@ end
217
217
  end
218
218
  =end
219
219
 
220
-
221
-
222
- # _____ _
223
- # |_ _|__ ___| |_
224
- # | |/ _ \/ __| __|
225
- # | | __/\__ \ |_
226
- # |_|\___||___/\__|
227
- #
228
-
229
- =begin test
230
- require 'test/unit'
231
-
232
- class TestBuildingBlock < Test::Unit::TestCase
233
-
234
- module M
235
- extend self
236
- def m(n,*m) ; "#{n}{#{m}}"; end
237
- def t(n) ; "#{n}"; end
238
- end
239
-
240
- def test_01
241
- build = BuildingBlock.new(M, :m)
242
-
243
- build.html do
244
- head do
245
- title "Test"
246
- end
247
-
248
- body do
249
- i "Hello"
250
- build! :not
251
- t "Test"
252
- t "Hey"
253
- end
254
- end
255
-
256
- r = "html{head{title{Test}}body{i{Hello}not{}TestHey}}"
257
-
258
- assert_equal( r, build.to_s )
259
- end
260
-
261
- end
262
-
263
- =end