diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-20 02:37:40 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-20 02:37:40 +0000 |
commit | 9ad5c7b5e23b4940e7a3ea3ca3a6fb77e6a8fab0 (patch) | |
tree | d088b5210e77d9fa91d954d8550e00e372b47378 /estimation-scripts/processlog.rb | |
download | ktorrent-9ad5c7b5e23b4940e7a3ea3ca3a6fb77e6a8fab0.tar.gz ktorrent-9ad5c7b5e23b4940e7a3ea3ca3a6fb77e6a8fab0.zip |
Updated to final KDE3 ktorrent release (2.2.6)
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/ktorrent@1077377 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'estimation-scripts/processlog.rb')
-rw-r--r-- | estimation-scripts/processlog.rb | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/estimation-scripts/processlog.rb b/estimation-scripts/processlog.rb new file mode 100644 index 0000000..c750ba5 --- /dev/null +++ b/estimation-scripts/processlog.rb @@ -0,0 +1,63 @@ +IDX_TIME = 0 +IDX_STATE = 5 + +def adjustTimestamps(perFile) + startTime = 0 + offset = 0 + lastDeactivation = -1 + lastSample = nil + + perFile.each_key do |file| + perFile[file].each do |line| + + time = line[0].to_i + + startTime = time if startTime == 0 + + time = time - startTime - offset + + line[IDX_TIME] = time.to_s + + if line[IDX_STATE] == 'RUNNING' + lastSample = line + elsif line[IDX_STATE] == 'ACTIVATED' + offset = time - lastDeactivation unless lastDeactivation == -1 + perFile[file].delete(line) + elsif line[IDX_STATE] == 'DEACTIVATED' + lastDeactivation = time + perFile[file].delete(line) + elsif line[IDX_STATE] == 'FINISHED' + # print last sample: time speed=0 downloaded left=0 peersTotal + # puts "#{line[0].to_i},0,#{lastSample[2].to_i + lastSample[3].to_i},0,#{lastSample[4].to_i}" + perFile[file].delete(line) + end + end + end +end + +perFile = Hash.new + +inputFile = File.new(ARGV[0]) + +inputFile.each do |line| + + splitted = line.strip.split(",") + if splitted.length == 7 + key = splitted[0] + perFile[key] = Array.new if perFile[key] == nil + perFile[key].push(splitted[1..6]) + end + +end + +inputFile.close + +adjustTimestamps(perFile) + +perFile.each_key do |file| + outfile = File.new("torrent-#{file}.log", "w") + perFile[file].each do |line| + outfile.puts line[0..4].join(",") + end + outfile.close +end |