-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBuildMeteo.rb
More file actions
69 lines (59 loc) · 1.92 KB
/
BuildMeteo.rb
File metadata and controls
69 lines (59 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Main function
if __FILE__ == $0
require 'CSV'
require './Estimate'
# For local testing purpose only
SRCE_DIR = './glib/'
DEST_DIR = './result/'
MAKAO_DIR = './makao/'
se = Estimate.new(SRCE_DIR, DEST_DIR);
# Step 0: setup the environment and generate gdf files using MAKAO
se.prep(MAKAO_DIR)
# First Step: Divide trace.gdf to edge_origin.gdf & node_origin.gdf
se.divide_gdf
# Second Step: Get files from git log
se.get_files_from_log
# Third Step: Output all the commit files paths to the commit_paths.txt used to test prediction result.
file = File.open("#{DEST_DIR}/all_changed_files.txt",'r')
file2 = File.open("#{DEST_DIR}/commit_paths.txt",'w')
array = file.readlines
array.each do |item|
item.delete("\n")
if item.start_with?('commit')
file2.syswrite("\n")
else
file2.syswrite("#{SRCE_DIR}/#{item} ")
end
end
# Fourth Step: Output all commit id to temp.txt
file = File.open("#{DEST_DIR}/all_changed_files.txt",'r')
file2 = File.open("#{DEST_DIR}/temp.txt", 'w')
array = file.readlines;
commit_array = Array.new
array.each do |item|
if item.start_with?('commit')
temp = item.split(' ')
commit_array.push(temp.last)
file2.syswrite(temp.last+"\n")
end
end
# Fifth Step: Predict build time for commits
file = File.open("#{DEST_DIR}/temp.txt",'r')
array = file.readlines
array_output = Array.new
loopvar = 0
array.each do |item|
estimated_time = se.predictTime(item, false) # Not testing the real time
array_output.push([item,estimated_time[0],estimated_time[1]])
loopvar += 1
break if loopvar >= 100 # Run 30 time for now
end
File.open("#{DEST_DIR}/commit_predict.csv",'w'){
|f|
f.write(array_output.inject([]) { |csv, row| csv << CSV.generate_line(row) }.join(''))
}
# Sixth Step: Test results
se.get_real_time
# The final prediction result: commit_predict.csv
# The real time: real_time.csv
end