Class: Nasl::CommandBenchmark

Inherits:
Command
  • Object
show all
Defined in:
lib/nasl/commands/benchmark.rb

Class Method Summary collapse

Methods inherited from Command

all, banner, find, inherited, initialize!, run

Class Method Details

.analyze(cfg, path, args) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/nasl/commands/benchmark.rb', line 35

def self.analyze(cfg, path, args)
  Benchmark.bmbm do |b|
    # Read in the file outside of the benchmark, to avoid contaminating it
    # with filesystem operations.
    contents = File.open(path, "rb").read

    b.report("Tokenize") do
      cfg[:iterations].times { Tokenizer.new(contents, path).get_tokens }
    end

    b.report("Parse") do
      cfg[:iterations].times { Parser.new.parse(contents) }
    end
  end
end

.bindingObject



31
32
33
# File 'lib/nasl/commands/benchmark.rb', line 31

def self.binding
  'benchmark'
end