mosso 0.0.2 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +14 -9
- data/lib/measure.rb +37 -0
- data/lib/mosso/version.rb +1 -1
- data/lib/mosso.rb +1 -5
- data/spec/mosso_spec.rb +6 -6
- metadata +3 -3
- data/lib/mosso/extension/mosso.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd53a6fcdc03df331ab16c53e4d9ff5571980a4e
|
4
|
+
data.tar.gz: 0962f00f7675b4119c69977a015979083b299996
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e973c990abe128df760b757f3b4f0b03978d65dfba1c7f192b6ad41b22456117793bc02a33da437e708ebcb1b37e2df276cb7fb857141ef9dabefa0895aa6661
|
7
|
+
data.tar.gz: 9314577c36ebf0da78c5306bd32a7360b45f6aaed6f8de2084d8ac5b671931c943f5548bd5f87183aaa6e4b549af6faa43f122f023a820320d88be07da8cdbcf
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -7,26 +7,31 @@ Module to measure the execution time.
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
9
|
gem 'mosso'
|
10
|
-
|
10
|
+
|
11
11
|
And then execute:
|
12
12
|
|
13
|
-
$ bundle
|
13
|
+
$ bundle install
|
14
14
|
|
15
15
|
Or install it yourself as:
|
16
16
|
|
17
17
|
$ gem install mosso
|
18
18
|
|
19
19
|
## Usage
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
require 'mosso'
|
21
|
+
|
22
|
+
m = Measure.new
|
23
|
+
...
|
24
|
+
...
|
25
|
+
...
|
26
|
+
puts m
|
27
|
+
|
28
|
+
STDOUT:
|
29
|
+
Exection Time: 2.000249151 [sec]
|
30
|
+
FileName: /home/user/products/gems/mosso/spec/mosso_spec.rb, Method: puts, Line: 32"
|
26
31
|
|
27
32
|
## Contributing
|
28
33
|
|
29
|
-
1. Fork it ( http://github.com
|
34
|
+
1. Fork it ( http://github.com/ryosy383/mosso/fork )
|
30
35
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
31
36
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
32
37
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/measure.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
class Measure
|
2
|
+
|
3
|
+
def initialize()
|
4
|
+
start()
|
5
|
+
end
|
6
|
+
|
7
|
+
def to_s
|
8
|
+
ret = []
|
9
|
+
file, line, method = parse_caller(caller.first)
|
10
|
+
ret << "Exection Time: #{exection_time()} [sec]"
|
11
|
+
ret << "FileName: #{file}, Method: #{method}, Line: #{line}"
|
12
|
+
ret << "\n"
|
13
|
+
ret.join("\n")
|
14
|
+
end
|
15
|
+
|
16
|
+
def start()
|
17
|
+
@start_time = Time.now
|
18
|
+
end
|
19
|
+
|
20
|
+
def reset()
|
21
|
+
start()
|
22
|
+
end
|
23
|
+
|
24
|
+
def exection_time()
|
25
|
+
Time.now - @start_time
|
26
|
+
end
|
27
|
+
|
28
|
+
def parse_caller(at)
|
29
|
+
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
|
30
|
+
file = $1
|
31
|
+
line = $2.to_i
|
32
|
+
method = $3
|
33
|
+
[file, line, method]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
data/lib/mosso/version.rb
CHANGED
data/lib/mosso.rb
CHANGED
data/spec/mosso_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe Mosso do
|
4
4
|
it 'should have a version number' do
|
5
5
|
Mosso::VERSION.should_not be_nil
|
6
|
-
Mosso::VERSION.should == "0.0.
|
6
|
+
Mosso::VERSION.should == "0.0.21"
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'should measure rightly the execution time' do
|
@@ -11,24 +11,24 @@ describe Mosso do
|
|
11
11
|
# initialize
|
12
12
|
measure = Measure.new
|
13
13
|
sleep 1
|
14
|
-
measure.exection_time().round.should
|
14
|
+
measure.exection_time().round.should be_eql(1)
|
15
15
|
puts measure
|
16
16
|
|
17
17
|
# exection_time
|
18
18
|
sleep 2
|
19
|
-
measure.exection_time().round.should
|
19
|
+
measure.exection_time().round.should be_eql(3)
|
20
20
|
puts measure
|
21
21
|
|
22
22
|
# reset
|
23
23
|
measure.reset
|
24
24
|
sleep 1
|
25
|
-
measure.exection_time().round.should
|
25
|
+
measure.exection_time().round.should be_eql(1)
|
26
26
|
puts measure
|
27
27
|
|
28
28
|
# start
|
29
29
|
measure.start
|
30
|
-
sleep
|
31
|
-
measure.exection_time().round.should
|
30
|
+
sleep 2
|
31
|
+
measure.exection_time().round.should be_eql(2)
|
32
32
|
puts measure
|
33
33
|
|
34
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mosso
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ryosy383
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,8 +66,8 @@ files:
|
|
66
66
|
- LICENSE.txt
|
67
67
|
- README.md
|
68
68
|
- Rakefile
|
69
|
+
- lib/measure.rb
|
69
70
|
- lib/mosso.rb
|
70
|
-
- lib/mosso/extension/mosso.rb
|
71
71
|
- lib/mosso/version.rb
|
72
72
|
- mosso.gemspec
|
73
73
|
- spec/mosso_spec.rb
|
@@ -1,23 +0,0 @@
|
|
1
|
-
class Measure
|
2
|
-
|
3
|
-
def initialize()
|
4
|
-
start()
|
5
|
-
end
|
6
|
-
|
7
|
-
def to_s
|
8
|
-
"Execution time: #{exection_time()} [sec]"
|
9
|
-
end
|
10
|
-
|
11
|
-
def start()
|
12
|
-
@start_time = Time.now
|
13
|
-
end
|
14
|
-
|
15
|
-
def reset()
|
16
|
-
start()
|
17
|
-
end
|
18
|
-
|
19
|
-
def exection_time()
|
20
|
-
Time.now - @start_time
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|