Skip to content

Commit 92eb8f6

Browse files
committed
Measure sandbox info fetching
1 parent 716e8f7 commit 92eb8f6

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

app/background_tasks/sandbox_status_fetcher_task.rb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# frozen_string_literal: true
22

33
require 'json'
4+
require 'benchmark'
45
require 'remote_sandbox'
56

67
class SandboxStatusFetcherTask
@@ -10,11 +11,16 @@ def initialize
1011

1112
def run
1213
data = @sandboxes.map do |sandbox|
13-
{
14-
baseurl: sandbox.baseurl,
15-
busy_instances: sandbox.busy_instances,
16-
capacity: sandbox.capacity,
17-
}
14+
data = nil
15+
fetching_time = Benchmark.measure do
16+
data = {
17+
baseurl: sandbox.baseurl,
18+
busy_instances: sandbox.busy_instances,
19+
capacity: sandbox.capacity,
20+
}
21+
end
22+
data[:fetching_time] = fetching_time.real.round(2)
23+
data
1824
end
1925
Rails.cache.write("sandbox-status-cache", data.to_json, expires_in: 1.minute)
2026
end

app/views/status/index.html.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
<th>Name</th>
5858
<th>Busy instances</th>
5959
<th>Capacity</th>
60+
<th>Time spent fething this information</th>
6061
</tr>
6162
</thead>
6263
<tbody>
@@ -66,6 +67,7 @@
6667
<td><%= sandbox['baseurl'] %></td>
6768
<td><%= sandbox['busy_instances'] %></td>
6869
<td><%= sandbox['capacity'] %></td>
70+
<td><%= sandbox['fetching_time'] %></td>
6971
</tr>
7072
<% end %>
7173
</tbody>

0 commit comments

Comments
 (0)