NL/Documentation/How Tos/Calc: functie INVERSEMAT
From Apache OpenOffice Wiki
- Copyright 2006 Google Inc.
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- OO.o build profile analyzer. To get the required patches look at:
- http://wiki.services.openoffice.org/wiki/BuildSpeedup
- Author: Kai Backman, kaib@google.com
import os import re import sys
def SortProfileTimes(lhs, rhs):
if lhs[1] < rhs[1]<>: return 1 elif rhs[1] < lhs[1]<>: return -1 else<>: return 0
def ProcessLogFile(file_name, target_durations):
- print "Processing file: " + file_name
file = open(file_name) start_time = 0 end_time = 0
target_start = 0 target_name = "" line = file.readline() while line<>!= ""<>: tokens = line[:-1].split(" ") line = file.readline()
if len(tokens) < 2<>: continue if tokens[1] == "build"<>: if tokens[0] == "s"<>: start_time = int(tokens[2]) * 1000 elif tokens[0] == "e"<>: end_time = int(tokens[2]) * 1000 elif tokens[1] == "target"<>: if tokens[0] == "s": target_start = int(tokens[2]) target_name = tokens[3] elif tokens[0] == "e" and target_name == tokens[3]: target_duration = int(tokens[2]) - target_start target_tokens = tokens[3].split(".") target_class = target_tokens[-1] if target_class in target_durations<>: target_durations[target_class] += target_duration else<>: target_durations[target_class] = target_duration file.close() return end_time - start_time return
if __name__ == "__main__":
target_durations = {} total_time = 0 for file_name in sys.argv[1:]<>: total_time += ProcessLogFile(file_name, target_durations)
profile = target_durations.items() profile.sort(SortProfileTimes) total_target_time = 0 for target_iter in profile<>: target_promille = target_iter[1] * 1000 / total_time if target_promille > 0<>: print "%6.ds<>%3.d.%1.d%%<>%s"<>% (target_iter[1] / 1000, target_promille/10, target_promille<>% 10, target_iter[0]) total_target_time += target_iter[1] print "Running time:<>%d s targets:<>%d s<>%d%%"<>% (total_time / 1000, total_target_time / 1000, total_target_time * 100 / total_time)