Class: Luna::Binary::BenchMark

Inherits:
Object
  • Object
show all
Defined in:
lib/luna/binary/benchmark.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(times, workspace, scheme) ⇒ BenchMark

Returns a new instance of BenchMark.



49
50
51
52
53
54
55
# File 'lib/luna/binary/benchmark.rb', line 49

def initialize(times, workspace, scheme)
    @times = times
    @workspace = workspace
    @scheme = scheme
    @binary_time_arr = []
    @normal_time_arr = []
end

Instance Attribute Details

#binary_time_arrObject (readonly)

Returns the value of attribute binary_time_arr.



46
47
48
# File 'lib/luna/binary/benchmark.rb', line 46

def binary_time_arr
  @binary_time_arr
end

#normal_time_arrObject (readonly)

Returns the value of attribute normal_time_arr.



47
48
49
# File 'lib/luna/binary/benchmark.rb', line 47

def normal_time_arr
  @normal_time_arr
end

#schemeObject (readonly)

Returns the value of attribute scheme.



45
46
47
# File 'lib/luna/binary/benchmark.rb', line 45

def scheme
  @scheme
end

#timesObject (readonly)

Returns the value of attribute times.



43
44
45
# File 'lib/luna/binary/benchmark.rb', line 43

def times
  @times
end

#workspaceObject (readonly)

Returns the value of attribute workspace.



44
45
46
# File 'lib/luna/binary/benchmark.rb', line 44

def workspace
  @workspace
end

Instance Method Details



86
87
88
89
# File 'lib/luna/binary/benchmark.rb', line 86

def print
    print_time_arr(normal_time_arr, "normal average time:")
    print_time_arr(binary_time_arr, "binary average time:")
end


91
92
93
94
95
96
97
98
99
100
# File 'lib/luna/binary/benchmark.rb', line 91

def print_time_arr(time_arr, attention)
    i = 0
    sum_time = 0
    time_arr.each { |item|
        item.print
        sum_time += item.delta
        i += 1
    }
    puts "#{attention} #{sum_time/i}" if sum_time > 0
end

#runObject



57
58
59
60
# File 'lib/luna/binary/benchmark.rb', line 57

def run
    run_binary
    run_no_binary
end

#run_binaryObject



62
63
64
65
# File 'lib/luna/binary/benchmark.rb', line 62

def run_binary
    Common.instance.command("lbu install")
    run_project(binary_time_arr)
end

#run_no_binaryObject



67
68
69
70
# File 'lib/luna/binary/benchmark.rb', line 67

def run_no_binary
    Common.instance.command("lbu install n")
    run_project(normal_time_arr)
end

#run_project(arr) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/luna/binary/benchmark.rb', line 72

def run_project(arr)
    i = 0
    while i < times
        Common.instance.command("xcodebuild clean -quiet -workspace #{workspace} -scheme #{scheme} -configuration Debug")
        t = DogTimer.new()
        t.start
        Common.instance.command("xcodebuild -workspace #{workspace} -scheme #{scheme} -configuration Debug")
        t.end
        arr << t
        i = i + 1
    end
end