walltime 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c0c9cdabcef08acc96490c9d1dfd49287d81e793
4
- data.tar.gz: 4defe9b27277004300f25baa09096fe5d9353fd0
3
+ metadata.gz: 80995fe2cc8e7d72e5986edc4a563dc580a304d2
4
+ data.tar.gz: 97516c3e049c29b348d159a8c43bdcd5318b2508
5
5
  SHA512:
6
- metadata.gz: 35fd09deec48f0bfa92a0d3bfbeb9df356265b7ae2c8da87cb2ae43fa45e24926f3a6f4a35865d69f3c6e5185b6e1d9d8c45026a9214f8ab9ab0976ae65fa6f9
7
- data.tar.gz: fa17a187ef69c1c3942b9d995458a8ab7355eb32bf159da4f174c15c52fc728a989df115e6ec72816ea8ff043c052118acc08490285df95ca452bc2117516bd8
6
+ metadata.gz: 4e0fe1ab3e178f657f6b82dafcce7cc8e3e26cee2112a1a3d4adc336169c120b597b218341e87689480528e9c98b4ff72231d47083dbfc6a9c23141deb28f36e
7
+ data.tar.gz: 7e4adb3188cdb2123f1246c313b41d3dd90e55834fee5ce55fee028fe889615bd74908432c2445d8e328d0aefaea6a73e5556d67bceb947bc470ae74f288668a
@@ -1,6 +1,4 @@
1
- require File.expand_path(File.join(
2
- File.dirname(__FILE__),
3
- "../lib/walltime.rb"))
1
+ require 'walltime'
4
2
 
5
3
  a = Stopwatch.new
6
4
  a.watch('start')
@@ -0,0 +1,97 @@
1
+ ########################################################################
2
+ #
3
+ # Author: Brian Hood
4
+ #
5
+ # Description: Milliseconds Example
6
+ #
7
+ # Display of Ruby refinements / Inheritance & Atomic Operation
8
+ # with Mutexes
9
+ ########################################################################
10
+
11
+
12
+ require 'walltime'
13
+
14
+ unless RUBY_VERSION > "2.0"
15
+ puts "Refinements only work in 2.0 and above"
16
+ exit
17
+ end
18
+
19
+ module TimeCustomize
20
+
21
+ refine Stopwatch do
22
+
23
+ def print_stats
24
+ round = round_to(@t2 - @t1, 2)
25
+ puts "Start: #{Time.at(@t1)} Finish: #{Time.at(@t2)} Total time: #{round}"
26
+ diff = (Time.at(@t2) - Time.at(@t1))*1000
27
+ puts "Difference: #{diff.to_s.gsub(".", "")[0..2]}ms"
28
+ end
29
+
30
+ end
31
+
32
+ end
33
+
34
+ =begin
35
+
36
+ Its seems you can't inherit a class without a refinement and add one in your new class i.e
37
+ You don't see the refined version of print_stats just the original
38
+
39
+ class MyClock
40
+
41
+ end
42
+
43
+ class MyClockInherit < MyClock
44
+
45
+ using TimeCustomize
46
+
47
+ end
48
+
49
+ However you can inherit an existing one
50
+
51
+ class MyClock
52
+
53
+ using TimeCustomize
54
+
55
+ end
56
+
57
+ class MyClockInherit < MyClock; end
58
+
59
+ As below
60
+ =end
61
+
62
+ class MyClock
63
+
64
+ using TimeCustomize
65
+
66
+ def initialize
67
+ @a = Stopwatch.new
68
+ @a.watch('start')
69
+ end
70
+
71
+ def delay(seconds)
72
+ sleep(seconds)
73
+ end
74
+
75
+ def end
76
+ @a.watch('stop')
77
+ @a.print_stats
78
+ end
79
+
80
+ end
81
+
82
+ class MyClockInherit < MyClock; end
83
+
84
+ # Pass the Mutex a &block
85
+ m = Mutex.new
86
+ m.synchronize do
87
+ clock = MyClock.new
88
+ clock.delay(0.234)
89
+ clock.end
90
+ end
91
+
92
+ n = Mutex.new
93
+ n.synchronize do
94
+ clock = MyClockInherit.new
95
+ clock.delay(0.234)
96
+ clock.end
97
+ end
@@ -0,0 +1,14 @@
1
+ module Walltime #:nodoc:
2
+
3
+ module VERSION #:nodoc:
4
+
5
+ MAJOR = 0
6
+ MINOR = 0
7
+ TINY = 6
8
+ CODENAME = "Its all Giraffes my son!"
9
+
10
+ STRING = [MAJOR, MINOR, TINY].join('.')
11
+
12
+ end
13
+
14
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: walltime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Hood
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-09 00:00:00.000000000 Z
11
+ date: 2015-09-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A Stopwatch you can use in all kinds of things
14
14
  email: brianh6854@googlemail.com
@@ -17,6 +17,8 @@ extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
19
  - examples/2seconds.rb
20
+ - examples/milliseconds.rb
21
+ - lib/version.rb
20
22
  - lib/walltime.rb
21
23
  homepage: https://github.com/puppetpies/Walltime
22
24
  licenses: