diff options
| author | Michele Calgaro <michele.calgaro@yahoo.it> | 2025-03-02 18:37:22 +0900 |
|---|---|---|
| committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2025-03-06 12:31:12 +0900 |
| commit | 44ef0bd5fe47a43e47aec5f7981b6c1d728dd9a8 (patch) | |
| tree | 2b29e921a9bccea53444ed9bbed06a25a5fe20cc /estimation-scripts/processlog.rb | |
| parent | d1f24dae035c506d945ca13f2be398aa0a4de8cc (diff) | |
| download | ktorrent-44ef0bd5fe47a43e47aec5f7981b6c1d728dd9a8.tar.gz ktorrent-44ef0bd5fe47a43e47aec5f7981b6c1d728dd9a8.zip | |
Restructure source files into 'src' subfolder
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'estimation-scripts/processlog.rb')
| -rw-r--r-- | estimation-scripts/processlog.rb | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/estimation-scripts/processlog.rb b/estimation-scripts/processlog.rb deleted file mode 100644 index c750ba5..0000000 --- a/estimation-scripts/processlog.rb +++ /dev/null @@ -1,63 +0,0 @@ -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 |
