computation 0.0.1 → 0.0.3

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.
@@ -1,8 +1,94 @@
1
1
  Feature: Computation Committee Calculations
2
2
  The computation model should generate correct committee calculations
3
3
 
4
- Scenario: Emission committee from default
4
+ Scenario: Compute units committee from default
5
5
  Given a computation emitter
6
- When the "emission" committee is calculated
6
+ When the "compute_units" committee is calculated
7
7
  Then the committee should have used quorum "default"
8
- And the conclusion of the committee should be "100.0"
8
+ And the conclusion of the committee should be "1"
9
+
10
+ Scenario: Compute time commitee from default
11
+ Given a computation emitter
12
+ When the "compute_time" committee is calculated
13
+ Then the committee should have used quorum "default"
14
+ And the conclusion of the committee should be "1.0"
15
+
16
+ Scenario: eGRID subregion committee from default
17
+ Given a computation emitter
18
+ When the "egrid_subregion" committee is calculated
19
+ Then the committee should have used quorum "default"
20
+ And the conclusion of the committee should have "abbreviation" of "US"
21
+
22
+ Scenario: eGRID subregion commitee from zip code
23
+ Given a computation emitter
24
+ And a characteristic "zip_code.name" of "94122"
25
+ When the "egrid_subregion" committee is calculated
26
+ Then the committee should have used quorum "from zip code"
27
+ And the conclusion of the committee should have "abbreviation" of "CAMX"
28
+
29
+ Scenario: eGRID region committee from default eGRID subregion
30
+ Given a computation emitter
31
+ When the "egrid_subregion" committee is calculated
32
+ And the "egrid_region" committee is calculated
33
+ Then the committee should have used quorum "from eGRID subregion"
34
+ And the conclusion of the committee should have "name" of "US"
35
+
36
+ Scenario: eGRID region committe from zip code
37
+ Given a computation emitter
38
+ And a characteristic "zip_code.name" of "94122"
39
+ When the "egrid_subregion" committee is calculated
40
+ And the "egrid_region" committee is calculated
41
+ Then the committee should have used quorum "from eGRID subregion"
42
+ And the conclusion of the committee should have "name" of "W"
43
+
44
+ Scenario: Compute electricity intensity commtitee from default
45
+ Given a computation emitter
46
+ When the "compute_electricity_intensity" committee is calculated
47
+ Then the committee should have used quorum "default"
48
+ And the conclusion of the committee should be "0.075"
49
+
50
+ Scenario: Power usage effectiveness commtitee from default
51
+ Given a computation emitter
52
+ When the "power_usage_effectiveness" committee is calculated
53
+ Then the committee should have used quorum "default"
54
+ And the conclusion of the committee should be "1.5"
55
+
56
+ Scenario: Electricity use commitee from default compute units, time, electricity intensity, zip code, and PUE
57
+ Given a computation emitter
58
+ When the "compute_units" committee is calculated
59
+ And the "compute_time" committee is calculated
60
+ And the "egrid_subregion" committee is calculated
61
+ And the "egrid_region" committee is calculated
62
+ And the "compute_electricity_intensity" committee is calculated
63
+ And the "power_usage_effectiveness" committee is calculated
64
+ And the "electricity_use" committee is calculated
65
+ Then the committee should have used quorum "from compute units, time, electricity intensity, PUE, and eGRID region"
66
+ And the conclusion of the committee should be "0.14063"
67
+
68
+ Scenario: Electricity use commitee from compute units, time, electricity intensity, zip code, and PUE
69
+ Given a computation emitter
70
+ And a characteristic "compute_units" of "10"
71
+ And a characteristic "compute_time" of "10"
72
+ And a characteristic "zip_code.name" of "94122"
73
+ And a characteristic "compute_electricity_intensity" of "1.0"
74
+ And a characteristic "power_usage_effectiveness" of "2.0"
75
+ And the "egrid_subregion" committee is calculated
76
+ And the "egrid_region" committee is calculated
77
+ And the "electricity_use" committee is calculated
78
+ Then the committee should have used quorum "from compute units, time, electricity intensity, PUE, and eGRID region"
79
+ And the conclusion of the committee should be "222.22222"
80
+
81
+ Scenario: Emission factor committee from default eGRID subregion
82
+ Given a computation emitter
83
+ When the "egrid_subregion" committee is calculated
84
+ And the "emission_factor" committee is calculated
85
+ Then the committee should have used quorum "from eGRID subregion"
86
+ And the conclusion of the committee should be "2.0"
87
+
88
+ Scenario: Emission factor committee from zip code
89
+ Given a computation emitter
90
+ And a characteristic "zip_code.name" of "94122"
91
+ When the "egrid_subregion" committee is calculated
92
+ And the "emission_factor" committee is calculated
93
+ Then the committee should have used quorum "from eGRID subregion"
94
+ And the conclusion of the committee should be "1.0"
@@ -4,4 +4,38 @@ Feature: Computation Emissions Calculations
4
4
  Scenario: Calculations starting from nothing
5
5
  Given a computation has nothing
6
6
  When emissions are calculated
7
- Then the emission value should be within "0.1" kgs of "100.0"
7
+ Then the emission value should be within "0.01" kgs of "0.28"
8
+
9
+ Scenario: Calculations starting from compute units
10
+ Given a computation has "compute_units" of "10"
11
+ When emissions are calculated
12
+ Then the emission value should be within "0.01" kgs of "2.81"
13
+
14
+ Scenario: Calculations starting from compute time
15
+ Given a computation has "compute_time" of "10"
16
+ When emissions are calculated
17
+ Then the emission value should be within "0.01" kgs of "2.81"
18
+
19
+ Scenario: Calculations starting from zip code
20
+ Given a computation has "zip_code.name" of "94122"
21
+ When emissions are calculated
22
+ Then the emission value should be within "0.01" kgs of "0.13"
23
+
24
+ Scenario: Calculations starting from compute electricity intensity
25
+ Given a computation has "compute_electricity_intensity" of "1.0"
26
+ When emissions are calculated
27
+ Then the emission value should be within "0.01" kgs of "3.75"
28
+
29
+ Scenario: Calculations starting from power usage effectiveness
30
+ Given a computation has "power_usage_effectiveness" of "2.0"
31
+ When emissions are calculated
32
+ Then the emission value should be within "0.01" kgs of "0.38"
33
+
34
+ Scenario: Calculations starting from compute units, time, electricity intensity, zip code, and PUE
35
+ Given a computation has "compute_units" of "10"
36
+ And it has "compute_time" of "10"
37
+ And it has "zip_code.name" of "94122"
38
+ And it has "compute_electricity_intensity" of "1.0"
39
+ And it has "power_usage_effectiveness" of "2.0"
40
+ When emissions are calculated
41
+ Then the emission value should be within "0.01" kgs of "222.22"
@@ -5,4 +5,4 @@ require 'cucumber'
5
5
  require 'cucumber/formatter/unicode'
6
6
 
7
7
  require 'sniff'
8
- Sniff.init File.join(File.dirname(__FILE__), '..', '..'), :cucumber => true, :earth => []
8
+ Sniff.init File.join(File.dirname(__FILE__), '..', '..'), :cucumber => true, :earth => :locality
@@ -4,8 +4,64 @@ module BrighterPlanet
4
4
  def self.included(base)
5
5
  base.decide :emission, :with => :characteristics do
6
6
  committee :emission do # returns kg CO2e
7
+ quorum 'from electricity use and emission factor', :needs => [:electricity_use, :emission_factor] do |characteristics|
8
+ characteristics[:electricity_use] * characteristics[:emission_factor]
9
+ end
10
+
11
+ quorum 'default' do
12
+ raise "The emission committee's default quorum should never be called."
13
+ end
14
+ end
15
+
16
+ committee :emission_factor do # returns kg co2e / kWh
17
+ quorum 'from eGRID subregion', :needs => :egrid_subregion do |characteristics|
18
+ characteristics[:egrid_subregion].electricity_emission_factor
19
+ end
20
+ end
21
+
22
+ committee :electricity_use do # returns kWh including distribution losses
23
+ quorum 'from compute units, time, electricity intensity, PUE, and eGRID region', :needs => [:compute_units, :compute_time, :compute_electricity_intensity, :power_usage_effectiveness, :egrid_region] do |characteristics|
24
+ (characteristics[:compute_units] * characteristics[:compute_time] * characteristics[:compute_electricity_intensity] * characteristics[:power_usage_effectiveness]) / (1 - characteristics[:egrid_region].loss_factor)
25
+ end
26
+ end
27
+
28
+ committee :power_usage_effectiveness do # returns data center total energy use / IT energy use
29
+ quorum 'default' do
30
+ base.fallback.power_usage_effectiveness
31
+ end
32
+ end
33
+
34
+ committee :compute_electricity_intensity do # returns kW (average load of IT infrastructure)
35
+ quorum 'default' do
36
+ base.fallback.compute_electricity_intensity
37
+ end
38
+ end
39
+
40
+ committee :egrid_region do # returns eGRID region
41
+ quorum 'from eGRID subregion', :needs => :egrid_subregion do |characteristics|
42
+ characteristics[:egrid_subregion].egrid_region
43
+ end
44
+ end
45
+
46
+ committee :egrid_subregion do # returns eGRID subregion
47
+ quorum 'from zip code', :needs => :zip_code do |characteristics|
48
+ characteristics[:zip_code].egrid_subregion
49
+ end
50
+
51
+ quorum 'default' do
52
+ EgridSubregion.find_by_abbreviation 'US'
53
+ end
54
+ end
55
+
56
+ committee :compute_time do # returns hours
57
+ quorum 'default' do
58
+ base.fallback.compute_time
59
+ end
60
+ end
61
+
62
+ committee :compute_units do # returns compute units (EC2 instances)
7
63
  quorum 'default' do
8
- 100.0
64
+ base.fallback.compute_units
9
65
  end
10
66
  end
11
67
  end
@@ -6,6 +6,10 @@ module BrighterPlanet
6
6
  def self.included(base)
7
7
  base.characterize do
8
8
  has :compute_time
9
+ has :compute_units
10
+ has :zip_code
11
+ has :compute_electricity_intensity
12
+ has :power_usage_effectiveness
9
13
  end
10
14
  end
11
15
  end
@@ -4,9 +4,13 @@ module BrighterPlanet
4
4
  def self.included(base)
5
5
  base.data_miner do
6
6
  schema do
7
- float :compute_time
7
+ float 'compute_time'
8
+ integer 'compute_units'
9
+ string 'zip_code_name'
10
+ float 'compute_electricity_intensity'
11
+ float 'power_usage_effectiveness'
8
12
  end
9
-
13
+
10
14
  process :run_data_miner_on_belongs_to_associations
11
15
  end
12
16
  end
@@ -5,4 +5,13 @@ require 'sniff'
5
5
  class ComputationRecord < ActiveRecord::Base
6
6
  include Sniff::Emitter
7
7
  include BrighterPlanet::Computation
8
+
9
+ belongs_to :zip_code, :foreign_key => 'zip_code_name'
10
+ belongs_to :egrid_subregion, :foreign_key => 'egrid_subregion_abbreviation'
11
+ belongs_to :egrid_region, :foreign_key => 'egrid_region_name'
12
+
13
+ falls_back_on :compute_time => 1.0, # assume 1 hour
14
+ :compute_units => 1, # assume 1 EC2 Unit
15
+ :power_usage_effectiveness => 1.5, # based on Amazon's EC2 cost comparison calculator statement that most data centers have PUE of 1.3 - 3.0
16
+ :compute_electricity_intensity => 0.075 # kW based on Amazon's EC2 cost comparison calculator stating 150W for small compute instance equivalent server and 0.5 power conversion factor (to get average operating load from nameplate capacity) - EC2 probably has lower draw but higher power conversion factor
8
17
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: computation
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andy Rossmeissl
@@ -19,14 +19,13 @@ autorequire:
19
19
  bindir: bin
20
20
  cert_chain: []
21
21
 
22
- date: 2010-09-21 00:00:00 -04:00
22
+ date: 2010-09-27 00:00:00 -07:00
23
23
  default_executable:
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
26
- type: :development
27
- prerelease: false
28
26
  name: activerecord
29
- version_requirements: &id001 !ruby/object:Gem::Requirement
27
+ prerelease: false
28
+ requirement: &id001 !ruby/object:Gem::Requirement
30
29
  none: false
31
30
  requirements:
32
31
  - - ~>
@@ -37,12 +36,12 @@ dependencies:
37
36
  - 0
38
37
  - 0
39
38
  version: 3.0.0
40
- requirement: *id001
41
- - !ruby/object:Gem::Dependency
42
39
  type: :development
43
- prerelease: false
40
+ version_requirements: *id001
41
+ - !ruby/object:Gem::Dependency
44
42
  name: bundler
45
- version_requirements: &id002 !ruby/object:Gem::Requirement
43
+ prerelease: false
44
+ requirement: &id002 !ruby/object:Gem::Requirement
46
45
  none: false
47
46
  requirements:
48
47
  - - ~>
@@ -53,12 +52,12 @@ dependencies:
53
52
  - 0
54
53
  - 0
55
54
  version: 1.0.0
56
- requirement: *id002
57
- - !ruby/object:Gem::Dependency
58
55
  type: :development
59
- prerelease: false
56
+ version_requirements: *id002
57
+ - !ruby/object:Gem::Dependency
60
58
  name: cucumber
61
- version_requirements: &id003 !ruby/object:Gem::Requirement
59
+ prerelease: false
60
+ requirement: &id003 !ruby/object:Gem::Requirement
62
61
  none: false
63
62
  requirements:
64
63
  - - ~>
@@ -69,12 +68,12 @@ dependencies:
69
68
  - 8
70
69
  - 3
71
70
  version: 0.8.3
72
- requirement: *id003
73
- - !ruby/object:Gem::Dependency
74
71
  type: :development
75
- prerelease: false
72
+ version_requirements: *id003
73
+ - !ruby/object:Gem::Dependency
76
74
  name: jeweler
77
- version_requirements: &id004 !ruby/object:Gem::Requirement
75
+ prerelease: false
76
+ requirement: &id004 !ruby/object:Gem::Requirement
78
77
  none: false
79
78
  requirements:
80
79
  - - ~>
@@ -85,12 +84,12 @@ dependencies:
85
84
  - 4
86
85
  - 0
87
86
  version: 1.4.0
88
- requirement: *id004
89
- - !ruby/object:Gem::Dependency
90
87
  type: :development
91
- prerelease: false
88
+ version_requirements: *id004
89
+ - !ruby/object:Gem::Dependency
92
90
  name: rake
93
- version_requirements: &id005 !ruby/object:Gem::Requirement
91
+ prerelease: false
92
+ requirement: &id005 !ruby/object:Gem::Requirement
94
93
  none: false
95
94
  requirements:
96
95
  - - ">="
@@ -99,12 +98,12 @@ dependencies:
99
98
  segments:
100
99
  - 0
101
100
  version: "0"
102
- requirement: *id005
103
- - !ruby/object:Gem::Dependency
104
101
  type: :development
105
- prerelease: false
102
+ version_requirements: *id005
103
+ - !ruby/object:Gem::Dependency
106
104
  name: rdoc
107
- version_requirements: &id006 !ruby/object:Gem::Requirement
105
+ prerelease: false
106
+ requirement: &id006 !ruby/object:Gem::Requirement
108
107
  none: false
109
108
  requirements:
110
109
  - - ">="
@@ -113,12 +112,12 @@ dependencies:
113
112
  segments:
114
113
  - 0
115
114
  version: "0"
116
- requirement: *id006
117
- - !ruby/object:Gem::Dependency
118
115
  type: :development
119
- prerelease: false
116
+ version_requirements: *id006
117
+ - !ruby/object:Gem::Dependency
120
118
  name: rspec
121
- version_requirements: &id007 !ruby/object:Gem::Requirement
119
+ prerelease: false
120
+ requirement: &id007 !ruby/object:Gem::Requirement
122
121
  none: false
123
122
  requirements:
124
123
  - - ~>
@@ -131,28 +130,28 @@ dependencies:
131
130
  - beta
132
131
  - 17
133
132
  version: 2.0.0.beta.17
134
- requirement: *id007
135
- - !ruby/object:Gem::Dependency
136
133
  type: :development
137
- prerelease: false
134
+ version_requirements: *id007
135
+ - !ruby/object:Gem::Dependency
138
136
  name: sniff
139
- version_requirements: &id008 !ruby/object:Gem::Requirement
137
+ prerelease: false
138
+ requirement: &id008 !ruby/object:Gem::Requirement
140
139
  none: false
141
140
  requirements:
142
141
  - - ~>
143
142
  - !ruby/object:Gem::Version
144
- hash: 3
143
+ hash: 23
145
144
  segments:
146
145
  - 0
147
- - 1
148
- - 12
149
- version: 0.1.12
150
- requirement: *id008
146
+ - 2
147
+ - 0
148
+ version: 0.2.0
149
+ type: :development
150
+ version_requirements: *id008
151
151
  - !ruby/object:Gem::Dependency
152
- type: :runtime
153
- prerelease: false
154
152
  name: emitter
155
- version_requirements: &id009 !ruby/object:Gem::Requirement
153
+ prerelease: false
154
+ requirement: &id009 !ruby/object:Gem::Requirement
156
155
  none: false
157
156
  requirements:
158
157
  - - ~>
@@ -163,7 +162,8 @@ dependencies:
163
162
  - 1
164
163
  - 3
165
164
  version: 0.1.3
166
- requirement: *id009
165
+ type: :runtime
166
+ version_requirements: *id009
167
167
  description: A software model in Ruby for the greenhouse gas emissions of a computer's computations
168
168
  email: andy@rossmeissl.net
169
169
  executables: []
@@ -182,7 +182,6 @@ files:
182
182
  - lib/computation/data.rb
183
183
  - lib/computation/summarization.rb
184
184
  - lib/test_support/computation_record.rb
185
- - lib/test_support/db/schema.rb
186
185
  - features/support/env.rb
187
186
  - features/computation_committees.feature
188
187
  - features/computation_emissions.feature
@@ -225,4 +224,3 @@ test_files:
225
224
  - features/computation_committees.feature
226
225
  - features/computation_emissions.feature
227
226
  - lib/test_support/computation_record.rb
228
- - lib/test_support/db/schema.rb
@@ -1,7 +0,0 @@
1
- require 'sniff/database'
2
-
3
- Sniff::Database.define_schema do
4
- create_table "computation_records", :force => true do |t|
5
- t.float 'compute_time'
6
- end
7
- end