Sha256: 4b06e715ad9cc5fc8e08521fc64001a0e0a915955f92766bf3bb1d6c9ede37e6

Contents?: true

Size: 1.64 KB

Versions: 1

Compression:

Stored size: 1.64 KB

Contents

module Mach5
  module Command
    module Chart
      def _all_charts
        @config.charts.each do |chart|
          _generate_chart(chart)
        end
      end

      def _only_charts(charts)
        @config.charts.each do |chart|
          if charts.include? chart.id
            _generate_chart(chart)
          end
        end
      end

      def _only_new_charts
        @config.charts.each do |chart|
          unless File.exists?("#{File.join(@config.output_folder, chart.id)}.png")
            _generate_chart(chart)
          end
        end
      end

      def _generate_chart(chart)
        benchmarks = _check_benchmarks(chart)
        _only_benchmarks(benchmarks) if benchmarks.size > 0
        Kernel.system "phantomjs #{File.join(File.dirname(__FILE__), "../js/chart.js")} #{File.join(File.dirname(__FILE__), "../js")} \"[#{chart.build.to_json.gsub("\"", "\\\"")}]\" #{File.join(@config.output_folder, chart.id)}.png"
      end

      def _check_benchmarks(chart)
        benchmarks = []
        chart.series.each do |benchmark|
          filename = _filename(benchmark[:commit_id], benchmark[:benchmark_id])
          benchmarks << "#{benchmark[:commit_id]}.#{benchmark[:benchmark_id]}" unless File.exists?(filename)
        end
        benchmarks
      end

      def _filename(commit_id, benchmark_id)
        if @config.benchmarks.tagged[commit_id]
          "#{File.join(@config.output_folder, @config.benchmarks.tagged[commit_id])}.#{benchmark_id}.json"
        else
          "#{File.join(@config.output_folder, commit_id)}.#{benchmark_id}.json"
        end
      end

      def list_charts
        @config.charts.map(&:id)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mach5-tools-0.3.0 lib/mach5-tools/command/chart.rb