aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2019-07-22 23:24:51 -0400
committerPaul Duncan <pabs@pablotron.org>2019-07-22 23:24:51 -0400
commite7b043da3446ce8f12994240b9094f18f03895d9 (patch)
tree8bf450833bb1ba5dd43c75824be7951c4697a27c
parente9f4904aafa025d0170782b3698865d62c0f5638 (diff)
downloadpi4-bench-e7b043da3446ce8f12994240b9094f18f03895d9.tar.bz2
pi4-bench-e7b043da3446ce8f12994240b9094f18f03895d9.zip
move sub-view logic into IndexHTMLView
-rwxr-xr-xrun.rb67
1 files changed, 39 insertions, 28 deletions
diff --git a/run.rb b/run.rb
index ddfcd61..9c6eb87 100755
--- a/run.rb
+++ b/run.rb
@@ -918,39 +918,20 @@ module PiBench
end
end
- class FullView < View
- def run
- # generate CSVs
- DataCSVsView.run(@model)
- HostsCSVView.run(@model)
-
- # render svgs, return svg info
- SVGView.run(@model)
-
- # create svg lists view
- view = SVGListHTMLView.new(@model)
-
- # render svg lists as html
- html = @model.svgs.reduce({}) do |r, pair|
- r[pair[0]] = view.run(pair[1])
- r
- end
-
- # render hosts section
- html[:hosts] = HostsSectionHTMLView.run(@model)
-
- # save index.html
- IndexHTMLView.new(@model).run(html)
- end
- end
-
#
# Generate and write out/index.html.
#
class IndexHTMLView < View
SECTIONS = %i{all arm x86}
- def run(html)
+ def initialize(model)
+ super(model)
+
+ # create/cache svg list view
+ @view = SVGListHTMLView.new(@model)
+ end
+
+ def run
File.write('%s/index.html' % [out_dir], TEMPLATES[:index].run({
title: 'OpenSSL Speed Test Results',
hosts: html[:hosts],
@@ -961,11 +942,41 @@ module PiBench
sections: SECTIONS.map { |arch|
TEMPLATES[:section].run({
- svgs: html[arch.to_s],
+ svgs: html[arch],
}.merge(ARCHS[arch]))
}.join,
}))
end
+
+ private
+
+ def html
+ # render svg lists as html
+ @html ||= @model.svgs.reduce({
+ # render hosts section
+ hosts: HostsSectionHTMLView.run(@model),
+ }) do |r, pair|
+ r[pair[0].intern] = @view.run(pair[1])
+ r
+ end
+ end
+ end
+
+ #
+ # Render everything.
+ #
+ class FullView < View
+ def run
+ # generate CSVs
+ DataCSVsView.run(@model)
+ HostsCSVView.run(@model)
+
+ # render svgs, return svg info
+ SVGView.run(@model)
+
+ # save index.html
+ IndexHTMLView.run(@model)
+ end
end
class Model