carbon 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +6 -0
- data/lib/carbon.rb +1 -0
- data/lib/carbon/version.rb +1 -1
- data/test/carbon_test.rb +44 -43
- metadata +15 -15
data/CHANGELOG
CHANGED
data/lib/carbon.rb
CHANGED
data/lib/carbon/version.rb
CHANGED
data/test/carbon_test.rb
CHANGED
@@ -91,55 +91,56 @@ describe Carbon do
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
@queries << ['Monkey']
|
104
|
-
end
|
105
|
-
@queries = @queries.sort_by { rand }
|
94
|
+
describe :multi do
|
95
|
+
before do
|
96
|
+
@queries = []
|
97
|
+
3.times do
|
98
|
+
@queries << ['Flight', {:origin_airport => 'LAX', :destination_airport => 'SFO', :segments_per_trip => 1, :trips => 1}]
|
99
|
+
@queries << ['RailTrip', {:distance => 25}]
|
100
|
+
@queries << ['AutomobileTrip', {:make => 'Nissan', :model => 'Altima'}]
|
101
|
+
@queries << ['Residence']
|
102
|
+
@queries << ['Monkey']
|
106
103
|
end
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
104
|
+
@queries = @queries.sort_by { rand }
|
105
|
+
end
|
106
|
+
it "doesn't hang up on 0 queries" do
|
107
|
+
Timeout.timeout(0.5) { Carbon.multi([]) }.must_equal []
|
108
|
+
end
|
109
|
+
it "runs multiple queries at once" do
|
110
|
+
responses = Carbon.multi(@queries)
|
111
|
+
error_count = 0
|
112
|
+
responses.each do |response|
|
113
|
+
if response.success
|
114
|
+
response.decisions.carbon.object.value.must_be :>, 0
|
115
|
+
response.decisions.carbon.object.value.must_be :<, 10_000
|
116
|
+
else
|
117
|
+
error_count += 1
|
117
118
|
end
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
119
|
+
end
|
120
|
+
error_count.must_equal 3
|
121
|
+
@queries.each_with_index do |query, i|
|
122
|
+
reference_response = Carbon.query(*query)
|
123
|
+
if reference_response.success
|
124
|
+
responses[i].decisions.must_equal reference_response.decisions
|
124
125
|
end
|
125
126
|
end
|
126
|
-
|
127
|
-
|
127
|
+
end
|
128
|
+
it "is faster than just calling #query over and over" do
|
129
|
+
# dry run
|
130
|
+
@queries.each { |query| Carbon.query(*query) }
|
131
|
+
# --
|
132
|
+
single_threaded_time = ::Benchmark.realtime do
|
128
133
|
@queries.each { |query| Carbon.query(*query) }
|
129
|
-
# --
|
130
|
-
single_threaded_time = ::Benchmark.realtime do
|
131
|
-
@queries.each { |query| Carbon.query(*query) }
|
132
|
-
end
|
133
|
-
multi_threaded_time = ::Benchmark.realtime do
|
134
|
-
Carbon.multi(@queries)
|
135
|
-
end
|
136
|
-
# Carbon::#multi
|
137
|
-
# PASS test_0001_runs_multiple_queries_at_once (12.10s)
|
138
|
-
# Multi-threaded was 95% faster
|
139
|
-
# PASS test_0002_is_faster_than_just_calling_query_over_and_over (23.73s)
|
140
|
-
$stderr.puts " Multi-threaded was #{((single_threaded_time - multi_threaded_time) / single_threaded_time * 100).round}% faster"
|
141
|
-
multi_threaded_time.must_be :<, single_threaded_time
|
142
134
|
end
|
135
|
+
multi_threaded_time = ::Benchmark.realtime do
|
136
|
+
Carbon.multi(@queries)
|
137
|
+
end
|
138
|
+
# Carbon::#multi
|
139
|
+
# PASS test_0001_runs_multiple_queries_at_once (12.10s)
|
140
|
+
# Multi-threaded was 95% faster
|
141
|
+
# PASS test_0002_is_faster_than_just_calling_query_over_and_over (23.73s)
|
142
|
+
$stderr.puts " Multi-threaded was #{((single_threaded_time - multi_threaded_time) / single_threaded_time * 100).round}% faster"
|
143
|
+
multi_threaded_time.must_be :<, single_threaded_time
|
143
144
|
end
|
144
145
|
end
|
145
146
|
describe "mixin" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carbon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-03-13 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: em-http-request
|
16
|
-
requirement: &
|
16
|
+
requirement: &2153871340 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2153871340
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activesupport
|
27
|
-
requirement: &
|
27
|
+
requirement: &2153870880 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2153870880
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: multi_json
|
38
|
-
requirement: &
|
38
|
+
requirement: &2153870440 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2153870440
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: hashie
|
49
|
-
requirement: &
|
49
|
+
requirement: &2153869980 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2153869980
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: bombshell
|
60
|
-
requirement: &
|
60
|
+
requirement: &2153869540 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2153869540
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: conversions
|
71
|
-
requirement: &
|
71
|
+
requirement: &2153869080 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2153869080
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: brighter_planet_metadata
|
82
|
-
requirement: &
|
82
|
+
requirement: &2153868640 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :runtime
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *2153868640
|
91
91
|
description: Brighter Planet API client for Ruby
|
92
92
|
email:
|
93
93
|
- seamus@abshere.net
|