Class: Benchcc::Clang
Overview
class Compiler
Instance Method Summary collapse
- #compile_file(file, *args) ⇒ Object
- #constexpr_depth ⇒ Object
-
#initialize(binary) ⇒ Clang
constructor
A new instance of Clang.
- #template_depth ⇒ Object
Methods inherited from Compiler
#compile_code, guess_from_binary, #to_s
Constructor Details
#initialize(binary) ⇒ Clang
Returns a new instance of Clang.
87 88 89 90 |
# File 'lib/benchcc/compiler.rb', line 87 def initialize(binary) @exe = `which #{binary}`.strip raise "#{binary} not found" unless $?.success? end |
Instance Method Details
#compile_file(file, *args) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/benchcc/compiler.rb', line 92 def compile_file(file, *args) file = Pathname.new(file). command = "/usr/bin/time -l #{@exe} #{args.join(' ')} -ftime-report #{file}" stdout, stderr, status = Open3.capture3(command) result = CompilationResult.new result.stderr = stderr result.stdout = stdout result.code = file.read result.command_line = command raise CompilationError.new(result) unless status.success? result.peak_memusg = stderr.match(/(\d+)\s+maximum/)[1].to_i section = -> (title) { title.gsub!(' ', '\s') /( ===-+===\n .*#{title}.*\n ===-+===\n (.|\n)+?(?====) )|( ===-+===\n .*#{title}.*\n ===-+===\n (.|\n)+ )/x } result.wall_time = stderr.match(section["Miscellaneous Ungrouped Timers"]) .to_s.match(/(\d+\.?\d+).+?Total/)[1] return result end |
#constexpr_depth ⇒ Object
126 |
# File 'lib/benchcc/compiler.rb', line 126 def constexpr_depth; 512; end |
#template_depth ⇒ Object
125 |
# File 'lib/benchcc/compiler.rb', line 125 def template_depth; 256; end |