tryouts 0.8.4 → 0.8.5
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.
- data/CHANGES.txt +20 -0
- data/lib/tryouts/drill/sergeant/benchmark.rb +24 -3
- data/lib/tryouts/drill/sergeant/cli.rb +1 -2
- data/lib/tryouts/drill.rb +10 -4
- data/lib/tryouts.rb +22 -11
- data/tryouts/30_benchmark_tryouts.rb +4 -5
- data/tryouts.gemspec +1 -1
- metadata +2 -2
data/CHANGES.txt
CHANGED
@@ -1,5 +1,25 @@
|
|
1
1
|
TRYOUTS, CHANGES
|
2
2
|
|
3
|
+
* TODO: consider having set create var= methods too.
|
4
|
+
* TODO: Support: "sergeant 30:52"
|
5
|
+
* TODO: FIXED: output for quiet mode
|
6
|
+
* TODO: Run clean after reports have been generated. See Gibbler 256 tryouts.
|
7
|
+
* TODO: Load tryouts/setup.rb and tryouts/clean.rb
|
8
|
+
* TODO: Support Hash syntax in set,
|
9
|
+
set :name => value
|
10
|
+
* TODO: Support tryouts/*_drills.rb and tryouts/*_tryout.rb
|
11
|
+
* TODO: Clear stash between drills
|
12
|
+
|
13
|
+
|
14
|
+
#### 0.8.5 (2009-10-07) ###############################
|
15
|
+
|
16
|
+
NOTE: Benchmark tryouts must now use proc style dreams
|
17
|
+
|
18
|
+
* CHANGE: Benchmark tryouts now display complex benchmark info
|
19
|
+
(utime, stime, cutime, cstime, total, real)
|
20
|
+
* CHANGE: Benchmark tryouts now run a brief warmup
|
21
|
+
* CHANGE: Improved startup time (via autoload)
|
22
|
+
|
3
23
|
|
4
24
|
#### 0.8.4 (2009-07-20) ###############################
|
5
25
|
|
@@ -13,11 +13,15 @@ class Tryouts; class Drill; module Sergeant
|
|
13
13
|
|
14
14
|
attr_reader :output
|
15
15
|
|
16
|
+
FIELDS = [:utime, :stime, :cutime, :cstime, :total, :real].freeze
|
17
|
+
|
16
18
|
# * +reps+ Number of times to execute drill (>= 0, <= 1000000). Default: 3
|
17
19
|
#
|
18
20
|
def initialize(reps=nil)
|
21
|
+
reps = 1 if reps.nil?
|
19
22
|
@reps = (1..1000000).include?(reps) ? reps : 5
|
20
|
-
@
|
23
|
+
@warmups = reps < 10 ? 1 : 10
|
24
|
+
@stats = {}
|
21
25
|
end
|
22
26
|
|
23
27
|
def run(block, context, &inline)
|
@@ -30,12 +34,20 @@ class Tryouts; class Drill; module Sergeant
|
|
30
34
|
else
|
31
35
|
begin
|
32
36
|
|
37
|
+
@warmups.times do
|
38
|
+
tms = ::Benchmark.measure {
|
39
|
+
context.instance_eval &runtime
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
@stats[:rtotal] = Tryouts::Stats.new(:rtotal)
|
33
44
|
@reps.times do
|
34
|
-
|
45
|
+
tms = ::Benchmark.measure {
|
35
46
|
context.instance_eval &runtime
|
36
47
|
}
|
37
|
-
|
48
|
+
process_tms(tms)
|
38
49
|
end
|
50
|
+
@stats[:rtotal].tick
|
39
51
|
|
40
52
|
# We add the output after we run the block so that
|
41
53
|
# that it'll remain nil if an exception was raised
|
@@ -51,5 +63,14 @@ class Tryouts; class Drill; module Sergeant
|
|
51
63
|
response
|
52
64
|
end
|
53
65
|
|
66
|
+
def process_tms(tms)
|
67
|
+
FIELDS.each do |f|
|
68
|
+
@stats[f] ||= Tryouts::Stats.new(f)
|
69
|
+
@stats[f].sample tms.send(f)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.fields() FIELDS end
|
74
|
+
|
54
75
|
end
|
55
76
|
end; end; end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
autoload :Rye, 'rye' # Make sure rye is loaded
|
2
2
|
|
3
3
|
class Tryouts; class Drill; module Sergeant
|
4
4
|
|
@@ -17,7 +17,6 @@ class Tryouts; class Drill; module Sergeant
|
|
17
17
|
attr_accessor :command
|
18
18
|
|
19
19
|
def initialize(*args)
|
20
|
-
require 'rye' # Make sure rye is loaded
|
21
20
|
@command = args.shift
|
22
21
|
@rbox_args = args
|
23
22
|
@rbox = Rye::Box.new
|
data/lib/tryouts/drill.rb
CHANGED
@@ -15,7 +15,7 @@ class Tryouts
|
|
15
15
|
require 'tryouts/drill/sergeant/cli'
|
16
16
|
require 'tryouts/drill/sergeant/api'
|
17
17
|
require 'tryouts/drill/sergeant/benchmark'
|
18
|
-
require 'tryouts/drill/sergeant/rbenchmark'
|
18
|
+
#require 'tryouts/drill/sergeant/rbenchmark'
|
19
19
|
|
20
20
|
class NoSergeant < Tryouts::Exception; end
|
21
21
|
class UnknownFormat < Tryouts::Exception; end
|
@@ -78,7 +78,7 @@ class Tryouts
|
|
78
78
|
dream_output, format, reps = args[1], args[0], args[2]
|
79
79
|
end
|
80
80
|
@sergeant = Tryouts::Drill::Sergeant::Benchmark.new reps
|
81
|
-
@dreams << Tryouts::Drill::Dream.new(
|
81
|
+
@dreams << Tryouts::Drill::Dream.new(Hash, :class)
|
82
82
|
unless dream_output.nil?
|
83
83
|
@dreams << Tryouts::Drill::Dream.new(dream_output, format)
|
84
84
|
end
|
@@ -133,8 +133,14 @@ class Tryouts
|
|
133
133
|
if Tryouts.verbose > 0
|
134
134
|
if @dtype == :benchmark
|
135
135
|
unless @reality.output.nil?
|
136
|
-
|
137
|
-
|
136
|
+
Sergeant::Benchmark.fields.each do |f|
|
137
|
+
s = @reality.output[f]
|
138
|
+
ar = [s.name, s.mean, s.min, s.max, s.sdev, s.sum]
|
139
|
+
pa = '%6s: %.4f (min:%.4f max:%.4f sdev:%.4f sum:%.4f)'.color(@clr)
|
140
|
+
out.puts pa % ar
|
141
|
+
end
|
142
|
+
ar = ['', @reality.output[:rtotal].mean]
|
143
|
+
out.puts '%8s%3.4f (run time)'.color(@clr) % ar
|
138
144
|
end
|
139
145
|
elsif @dtype == :cli
|
140
146
|
out.puts '%6s%s'.color(@clr) % ['', @reality.command]
|
data/lib/tryouts.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
|
2
2
|
require 'time'
|
3
|
-
require 'attic'
|
4
|
-
require 'sysinfo'
|
5
3
|
require 'digest/sha1'
|
6
|
-
|
7
|
-
|
4
|
+
|
5
|
+
autoload :Attic, 'attic'
|
6
|
+
autoload :SysInfo, 'sysinfo'
|
7
|
+
autoload :OpenStruct, 'ostruct'
|
8
|
+
autoload :YAML, 'yaml'
|
8
9
|
|
9
10
|
## NOTE: Don't require rye here so
|
10
11
|
## we can still run tryouts on the
|
@@ -46,22 +47,29 @@ class Tryouts
|
|
46
47
|
end
|
47
48
|
end
|
48
49
|
|
49
|
-
VERSION = "0.8.
|
50
|
+
VERSION = "0.8.5"
|
50
51
|
|
51
52
|
require 'tryouts/mixins'
|
52
53
|
require 'tryouts/tryout'
|
53
54
|
require 'tryouts/drill'
|
54
|
-
require 'tryouts/stats'
|
55
55
|
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
autoload :Stats, 'tryouts/stats'
|
57
|
+
|
58
|
+
unless defined?(HASH_TYPE)
|
59
|
+
if RUBY_VERSION =~ /1.8/
|
60
|
+
require 'tryouts/orderedhash'
|
61
|
+
HASH_TYPE = Tryouts::OrderedHash
|
62
|
+
else
|
63
|
+
HASH_TYPE = Hash
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
59
67
|
# An Array of +_tryouts.rb+ file paths that have been loaded.
|
60
68
|
@@loaded_files = []
|
61
69
|
# An Hash of Tryouts instances stored under the name of the Tryouts subclass.
|
62
70
|
@@instances = HASH_TYPE.new
|
63
71
|
# An instance of SysInfo
|
64
|
-
@@sysinfo =
|
72
|
+
@@sysinfo = nil
|
65
73
|
|
66
74
|
@@debug = false
|
67
75
|
@@verbose = 0
|
@@ -81,7 +89,10 @@ class Tryouts
|
|
81
89
|
# Returns +@@instances+
|
82
90
|
def self.instances; @@instances; end
|
83
91
|
# Returns +@@sysinfo+
|
84
|
-
def self.sysinfo
|
92
|
+
def self.sysinfo
|
93
|
+
@@sysinfo = SysInfo.new if @@sysinfo.nil?
|
94
|
+
@@sysinfo
|
95
|
+
end
|
85
96
|
|
86
97
|
# The name of this group of Tryout objects
|
87
98
|
attr_accessor :group
|
@@ -4,24 +4,23 @@ group "Benchmarks"
|
|
4
4
|
|
5
5
|
tryouts "Benchmark Syntax", :benchmark do
|
6
6
|
|
7
|
-
drill "can check the mean is <="
|
7
|
+
drill "can check the mean is <=" do
|
8
8
|
sleep 0.1
|
9
9
|
end
|
10
10
|
|
11
|
-
drill "can check the standard deviation"
|
11
|
+
drill "can check the standard deviation" do
|
12
12
|
sleep 0.1
|
13
13
|
end
|
14
14
|
|
15
|
-
drill "Tryouts::Stat objects have a default name"
|
15
|
+
drill "Tryouts::Stat objects have a default name" do
|
16
16
|
sleep 0.1
|
17
17
|
end
|
18
18
|
|
19
|
-
dream :samples, 5
|
20
19
|
drill "default repetitions is 5" do
|
21
20
|
sleep 0.1
|
22
21
|
end
|
23
22
|
|
24
|
-
dream :proc, lambda { |x| x.sum >= 0.5 }
|
23
|
+
dream :proc, lambda { |x| x[:real].sum >= 0.5 }
|
25
24
|
drill "can specify dream proc" do
|
26
25
|
sleep 0.1
|
27
26
|
end
|
data/tryouts.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
@spec = Gem::Specification.new do |s|
|
2
2
|
s.name = "tryouts"
|
3
3
|
s.rubyforge_project = "tryouts"
|
4
|
-
s.version = "0.8.
|
4
|
+
s.version = "0.8.5"
|
5
5
|
s.summary = "Tryouts is a high-level testing library (DSL) for your Ruby codes and command-line applications."
|
6
6
|
s.description = s.summary
|
7
7
|
s.author = "Delano Mandelbaum"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tryouts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Delano Mandelbaum
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-07
|
12
|
+
date: 2009-10-07 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|