Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Commit

Permalink
Revert "Fix order of magnitude in CPU consumption reported by cf app"
Browse files Browse the repository at this point in the history
This reverts commit f48b915.
  • Loading branch information
jberkhahn committed Jun 14, 2016
1 parent f48b915 commit 87acf5f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/dea/stat_collector.rb
Expand Up @@ -48,7 +48,7 @@ def compute_cpu_usage(usage, now)
elapsed = @cpu_samples[1][:timestamp_ns] - @cpu_samples[0][:timestamp_ns]

if elapsed > 0
@computed_pcpu = (used * 100).to_f / (elapsed*100)
@computed_pcpu = (used * 100).to_f / elapsed
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/unit/stat_collector_spec.rb
Expand Up @@ -152,7 +152,7 @@
time_between_stats = (Dea::StatCollector::INTERVAL * NANOSECONDS_PER_SECOND)

expect(@emitter.messages['application-id'].length).to eq(2)
expect(@emitter.messages['application-id'][1][:cpuPercentage]).to eq((10_000_000_000 - 5_000_000) / time_between_stats)
expect(@emitter.messages['application-id'][1][:cpuPercentage]).to eq((10_000_000_000 - 5_000_000) * 100 / time_between_stats)
end

it 'updates the statistic variables' do
Expand All @@ -163,7 +163,7 @@
collector.emit_metrics(time + Dea::StatCollector::INTERVAL)

time_between_stats = (Dea::StatCollector::INTERVAL * NANOSECONDS_PER_SECOND)
expected_pcpu = (10_000_000_000 - 5_000_000) / time_between_stats
expected_pcpu = (10_000_000_000 - 5_000_000) * 100 / time_between_stats

expect(collector.computed_pcpu).to eq(expected_pcpu)
expect(collector.used_memory_in_bytes).to eq(1000)
Expand All @@ -190,7 +190,7 @@
collector.emit_metrics(time + Dea::StatCollector::INTERVAL)

time_between_stats = (Dea::StatCollector::INTERVAL * NANOSECONDS_PER_SECOND)
expected_pcpu = (10_000_000_000 - 5_000_000) / time_between_stats
expected_pcpu = (10_000_000_000 - 5_000_000) * 100 / time_between_stats

expect(@emitter.messages['application-id'].length).to eq(2)
expect(@emitter.messages['application-id'][1][:cpuPercentage]).to eq(expected_pcpu)
Expand Down

0 comments on commit 87acf5f

Please sign in to comment.