Normalize line endings and whitespace

This commit is contained in:
OpenCV Buildbot
2012-10-17 11:12:04 +04:00
committed by Andrey Kamaev
parent 0442bca235
commit 81f826db2b
1511 changed files with 258678 additions and 258624 deletions

38
modules/ts/misc/chart.py Normal file → Executable file
View File

@@ -32,7 +32,7 @@ def keyselector(a):
return ((channels-1) & 511) + (depth << 9)
return a
convert = lambda text: int(text) if text.isdigit() else text
convert = lambda text: int(text) if text.isdigit() else text
alphanum_keyselector = lambda key: [ convert(c) for c in re.split('([0-9]+)', str(keyselector(key))) ]
def getValueParams(test):
@@ -95,13 +95,13 @@ def getTestWideName(sname, indexes, lists, x, y):
name += "Y"
else:
name += lists[i][indexes[i]]
return str(name + ")")
return str(name + ")")
def getTest(stests, x, y, row, col):
for pair in stests:
if pair[1][x] == row and pair[1][y] == col:
return pair[0]
return None
return None
if __name__ == "__main__":
parser = OptionParser()
@@ -112,7 +112,7 @@ if __name__ == "__main__":
parser.add_option("-y", "", dest="y", help="argument number for columns", metavar="COL", default=0)
parser.add_option("-f", "--filter", dest="filter", help="regex to filter tests", metavar="REGEX", default=None)
(options, args) = parser.parse_args()
if len(args) != 1:
print >> sys.stderr, "Usage:\n", os.path.basename(sys.argv[0]), "<log_name1>.xml"
exit(1)
@@ -123,27 +123,27 @@ if __name__ == "__main__":
if options.metric.endswith("%"):
options.metric = options.metric[:-1]
getter = metrix_table[options.metric][1]
tests = testlog_parser.parseLogFile(args[0])
if options.filter:
expr = re.compile(options.filter)
tests = [(t,getValueParams(t)) for t in tests if expr.search(str(t))]
else:
tests = [(t,getValueParams(t)) for t in tests]
args[0] = os.path.basename(args[0])
if not tests:
print >> sys.stderr, "Error - no tests matched"
exit(1)
argsnum = len(tests[0][1])
sname = tests[0][0].shortName()
arglists = []
for i in range(argsnum):
arglists.append({})
names = set()
names1 = set()
for pair in tests:
@@ -158,7 +158,7 @@ if __name__ == "__main__":
sys.exit(1)
for i in range(argsnum):
arglists[i][pair[1][i]] = 1
if names1 or len(names) != 1:
print >> sys.stderr, "Error - unable to create tables for functions from different test suits:"
i = 1
@@ -171,24 +171,24 @@ if __name__ == "__main__":
print >> sys.stderr, "%4s: %s" % (i, name)
i += 1
sys.exit(1)
if argsnum < 2:
print >> sys.stderr, "Error - tests from %s have less than 2 parameters" % sname
exit(1)
for i in range(argsnum):
arglists[i] = sorted([str(key) for key in arglists[i].iterkeys()], key=alphanum_keyselector)
if options.generateHtml and options.format != "moinwiki":
htmlPrintHeader(sys.stdout, "Report %s for %s" % (args[0], sname))
indexes = [0] * argsnum
x = int(options.x)
y = int(options.y)
if x == y or x < 0 or y < 0 or x >= argsnum or y >= argsnum:
x = 1
y = 0
while True:
stests = []
for pair in tests:
@@ -223,13 +223,13 @@ if __name__ == "__main__":
tbl.newCell(col, val, val)
else:
tbl.newCell(col, "-")
if options.generateHtml:
tbl.htmlPrintTable(sys.stdout, options.format == "moinwiki")
else:
tbl.consolePrintTable(sys.stdout)
if not nextPermutation(indexes, arglists, x, y):
break
if options.generateHtml and options.format != "moinwiki":
htmlPrintFooter(sys.stdout)

768
modules/ts/misc/color.py Normal file → Executable file
View File

@@ -1,384 +1,384 @@
import math, os, sys
webcolors = {
"indianred": "#cd5c5c",
"lightcoral": "#f08080",
"salmon": "#fa8072",
"darksalmon": "#e9967a",
"lightsalmon": "#ffa07a",
"red": "#ff0000",
"crimson": "#dc143c",
"firebrick": "#b22222",
"darkred": "#8b0000",
"pink": "#ffc0cb",
"lightpink": "#ffb6c1",
"hotpink": "#ff69b4",
"deeppink": "#ff1493",
"mediumvioletred": "#c71585",
"palevioletred": "#db7093",
"lightsalmon": "#ffa07a",
"coral": "#ff7f50",
"tomato": "#ff6347",
"orangered": "#ff4500",
"darkorange": "#ff8c00",
"orange": "#ffa500",
"gold": "#ffd700",
"yellow": "#ffff00",
"lightyellow": "#ffffe0",
"lemonchiffon": "#fffacd",
"lightgoldenrodyellow": "#fafad2",
"papayawhip": "#ffefd5",
"moccasin": "#ffe4b5",
"peachpuff": "#ffdab9",
"palegoldenrod": "#eee8aa",
"khaki": "#f0e68c",
"darkkhaki": "#bdb76b",
"lavender": "#e6e6fa",
"thistle": "#d8bfd8",
"plum": "#dda0dd",
"violet": "#ee82ee",
"orchid": "#da70d6",
"fuchsia": "#ff00ff",
"magenta": "#ff00ff",
"mediumorchid": "#ba55d3",
"mediumpurple": "#9370db",
"blueviolet": "#8a2be2",
"darkviolet": "#9400d3",
"darkorchid": "#9932cc",
"darkmagenta": "#8b008b",
"purple": "#800080",
"indigo": "#4b0082",
"darkslateblue": "#483d8b",
"slateblue": "#6a5acd",
"mediumslateblue": "#7b68ee",
"greenyellow": "#adff2f",
"chartreuse": "#7fff00",
"lawngreen": "#7cfc00",
"lime": "#00ff00",
"limegreen": "#32cd32",
"palegreen": "#98fb98",
"lightgreen": "#90ee90",
"mediumspringgreen": "#00fa9a",
"springgreen": "#00ff7f",
"mediumseagreen": "#3cb371",
"seagreen": "#2e8b57",
"forestgreen": "#228b22",
"green": "#008000",
"darkgreen": "#006400",
"yellowgreen": "#9acd32",
"olivedrab": "#6b8e23",
"olive": "#808000",
"darkolivegreen": "#556b2f",
"mediumaquamarine": "#66cdaa",
"darkseagreen": "#8fbc8f",
"lightseagreen": "#20b2aa",
"darkcyan": "#008b8b",
"teal": "#008080",
"aqua": "#00ffff",
"cyan": "#00ffff",
"lightcyan": "#e0ffff",
"paleturquoise": "#afeeee",
"aquamarine": "#7fffd4",
"turquoise": "#40e0d0",
"mediumturquoise": "#48d1cc",
"darkturquoise": "#00ced1",
"cadetblue": "#5f9ea0",
"steelblue": "#4682b4",
"lightsteelblue": "#b0c4de",
"powderblue": "#b0e0e6",
"lightblue": "#add8e6",
"skyblue": "#87ceeb",
"lightskyblue": "#87cefa",
"deepskyblue": "#00bfff",
"dodgerblue": "#1e90ff",
"cornflowerblue": "#6495ed",
"royalblue": "#4169e1",
"blue": "#0000ff",
"mediumblue": "#0000cd",
"darkblue": "#00008b",
"navy": "#000080",
"midnightblue": "#191970",
"cornsilk": "#fff8dc",
"blanchedalmond": "#ffebcd",
"bisque": "#ffe4c4",
"navajowhite": "#ffdead",
"wheat": "#f5deb3",
"burlywood": "#deb887",
"tan": "#d2b48c",
"rosybrown": "#bc8f8f",
"sandybrown": "#f4a460",
"goldenrod": "#daa520",
"darkgoldenrod": "#b8860b",
"peru": "#cd853f",
"chocolate": "#d2691e",
"saddlebrown": "#8b4513",
"sienna": "#a0522d",
"brown": "#a52a2a",
"maroon": "#800000",
"white": "#ffffff",
"snow": "#fffafa",
"honeydew": "#f0fff0",
"mintcream": "#f5fffa",
"azure": "#f0ffff",
"aliceblue": "#f0f8ff",
"ghostwhite": "#f8f8ff",
"whitesmoke": "#f5f5f5",
"seashell": "#fff5ee",
"beige": "#f5f5dc",
"oldlace": "#fdf5e6",
"floralwhite": "#fffaf0",
"ivory": "#fffff0",
"antiquewhite": "#faebd7",
"linen": "#faf0e6",
"lavenderblush": "#fff0f5",
"mistyrose": "#ffe4e1",
"gainsboro": "#dcdcdc",
"lightgrey": "#d3d3d3",
"silver": "#c0c0c0",
"darkgray": "#a9a9a9",
"gray": "#808080",
"dimgray": "#696969",
"lightslategray": "#778899",
"slategray": "#708090",
"darkslategray": "#2f4f4f",
"black": "#000000",
}
if os.name == "nt":
consoleColors = [
"#000000", #{ 0, 0, 0 },//0 - black
"#000080", #{ 0, 0, 128 },//1 - navy
"#008000", #{ 0, 128, 0 },//2 - green
"#008080", #{ 0, 128, 128 },//3 - teal
"#800000", #{ 128, 0, 0 },//4 - maroon
"#800080", #{ 128, 0, 128 },//5 - purple
"#808000", #{ 128, 128, 0 },//6 - olive
"#C0C0C0", #{ 192, 192, 192 },//7 - silver
"#808080", #{ 128, 128, 128 },//8 - gray
"#0000FF", #{ 0, 0, 255 },//9 - blue
"#00FF00", #{ 0, 255, 0 },//a - lime
"#00FFFF", #{ 0, 255, 255 },//b - cyan
"#FF0000", #{ 255, 0, 0 },//c - red
"#FF00FF", #{ 255, 0, 255 },//d - magenta
"#FFFF00", #{ 255, 255, 0 },//e - yellow
"#FFFFFF", #{ 255, 255, 255 } //f - white
]
else:
consoleColors = [
"#2e3436",
"#cc0000",
"#4e9a06",
"#c4a000",
"#3465a4",
"#75507b",
"#06989a",
"#d3d7cf",
"#ffffff",
"#555753",
"#ef2929",
"#8ae234",
"#fce94f",
"#729fcf",
"#ad7fa8",
"#34e2e2",
"#eeeeec",
]
def RGB2LAB(r,g,b):
if max(r,g,b):
r /= 255.
g /= 255.
b /= 255.
X = (0.412453 * r + 0.357580 * g + 0.180423 * b) / 0.950456
Y = (0.212671 * r + 0.715160 * g + 0.072169 * b)
Z = (0.019334 * r + 0.119193 * g + 0.950227 * b) / 1.088754
#[X * 0.950456] [0.412453 0.357580 0.180423] [R]
#[Y ] = [0.212671 0.715160 0.072169] * [G]
#[Z * 1.088754] [0.019334 0.119193 0.950227] [B]
T = 0.008856 #threshold
if X > T:
fX = math.pow(X, 1./3.)
else:
fX = 7.787 * X + 16./116.
# Compute L
if Y > T:
Y3 = math.pow(Y, 1./3.)
fY = Y3
L = 116. * Y3 - 16.0
else:
fY = 7.787 * Y + 16./116.
L = 903.3 * Y
if Z > T:
fZ = math.pow(Z, 1./3.)
else:
fZ = 7.787 * Z + 16./116.
# Compute a and b
a = 500. * (fX - fY)
b = 200. * (fY - fZ)
return (L,a,b)
def colorDistance(r1,g1,b1 = None, r2 = None, g2 = None,b2 = None):
if type(r1) == tuple and type(g1) == tuple and b1 is None and r2 is None and g2 is None and b2 is None:
(l1,a1,b1) = RGB2LAB(*r1)
(l2,a2,b2) = RGB2LAB(*g1)
else:
(l1,a1,b1) = RGB2LAB(r1,g1,b1)
(l2,a2,b2) = RGB2LAB(r2,g2,b2)
#CIE94
dl = l1-l2
C1 = math.sqrt(a1*a1 + b1*b1)
C2 = math.sqrt(a2*a2 + b2*b2)
dC = C1 - C2
da = a1-a2
db = b1-b2
dH = math.sqrt(max(0, da*da + db*db - dC*dC))
Kl = 1
K1 = 0.045
K2 = 0.015
s1 = dl/Kl
s2 = dC/(1. + K1 * C1)
s3 = dH/(1. + K2 * C1)
return math.sqrt(s1*s1 + s2*s2 + s3*s3)
def parseHexColor(col):
if len(col) != 4 and len(col) != 7 and not col.startswith("#"):
return (0,0,0)
if len(col) == 4:
r = col[1]*2
g = col[2]*2
b = col[3]*2
else:
r = col[1:3]
g = col[3:5]
b = col[5:7]
return (int(r,16), int(g,16), int(b,16))
def getColor(col):
if isinstance(col, str):
if col.lower() in webcolors:
return parseHexColor(webcolors[col.lower()])
else:
return parseHexColor(col)
else:
return col
def getNearestConsoleColor(col):
color = getColor(col)
minidx = 0
mindist = colorDistance(color, getColor(consoleColors[0]))
for i in range(len(consoleColors)):
dist = colorDistance(color, getColor(consoleColors[i]))
if dist < mindist:
mindist = dist
minidx = i
return minidx
if os.name == 'nt':
import msvcrt
from ctypes import windll, Structure, c_short, c_ushort, byref
SHORT = c_short
WORD = c_ushort
class COORD(Structure):
_fields_ = [
("X", SHORT),
("Y", SHORT)]
class SMALL_RECT(Structure):
_fields_ = [
("Left", SHORT),
("Top", SHORT),
("Right", SHORT),
("Bottom", SHORT)]
class CONSOLE_SCREEN_BUFFER_INFO(Structure):
_fields_ = [
("dwSize", COORD),
("dwCursorPosition", COORD),
("wAttributes", WORD),
("srWindow", SMALL_RECT),
("dwMaximumWindowSize", COORD)]
class winConsoleColorizer(object):
def __init__(self, stream):
self.handle = msvcrt.get_osfhandle(stream.fileno())
self.default_attrs = 7#self.get_text_attr()
self.stream = stream
def get_text_attr(self):
csbi = CONSOLE_SCREEN_BUFFER_INFO()
windll.kernel32.GetConsoleScreenBufferInfo(self.handle, byref(csbi))
return csbi.wAttributes
def set_text_attr(self, color):
windll.kernel32.SetConsoleTextAttribute(self.handle, color)
def write(self, *text, **attrs):
if not text:
return
color = attrs.get("color", None)
if color:
col = getNearestConsoleColor(color)
self.stream.flush()
self.set_text_attr(col)
self.stream.write(" ".join([str(t) for t in text]))
if color:
self.stream.flush()
self.set_text_attr(self.default_attrs)
class dummyColorizer(object):
def __init__(self, stream):
self.stream = stream
def write(self, *text, **attrs):
if text:
self.stream.write(" ".join([str(t) for t in text]))
class asciiSeqColorizer(object):
RESET_SEQ = "\033[0m"
#BOLD_SEQ = "\033[1m"
ITALIC_SEQ = "\033[3m"
UNDERLINE_SEQ = "\033[4m"
STRIKEOUT_SEQ = "\033[9m"
COLOR_SEQ0 = "\033[00;%dm" #dark
COLOR_SEQ1 = "\033[01;%dm" #bold and light
def __init__(self, stream):
self.stream = stream
def get_seq(self, code):
if code > 8:
return self.__class__.COLOR_SEQ1 % (30 + code - 9)
else:
return self.__class__.COLOR_SEQ0 % (30 + code)
def write(self, *text, **attrs):
if not text:
return
color = attrs.get("color", None)
if color:
col = getNearestConsoleColor(color)
self.stream.write(self.get_seq(col))
self.stream.write(" ".join([str(t) for t in text]))
if color:
self.stream.write(self.__class__.RESET_SEQ)
def getColorizer(stream):
if stream.isatty():
if os.name == "nt":
return winConsoleColorizer(stream)
else:
return asciiSeqColorizer(stream)
else:
return dummyColorizer(stream)
import math, os, sys
webcolors = {
"indianred": "#cd5c5c",
"lightcoral": "#f08080",
"salmon": "#fa8072",
"darksalmon": "#e9967a",
"lightsalmon": "#ffa07a",
"red": "#ff0000",
"crimson": "#dc143c",
"firebrick": "#b22222",
"darkred": "#8b0000",
"pink": "#ffc0cb",
"lightpink": "#ffb6c1",
"hotpink": "#ff69b4",
"deeppink": "#ff1493",
"mediumvioletred": "#c71585",
"palevioletred": "#db7093",
"lightsalmon": "#ffa07a",
"coral": "#ff7f50",
"tomato": "#ff6347",
"orangered": "#ff4500",
"darkorange": "#ff8c00",
"orange": "#ffa500",
"gold": "#ffd700",
"yellow": "#ffff00",
"lightyellow": "#ffffe0",
"lemonchiffon": "#fffacd",
"lightgoldenrodyellow": "#fafad2",
"papayawhip": "#ffefd5",
"moccasin": "#ffe4b5",
"peachpuff": "#ffdab9",
"palegoldenrod": "#eee8aa",
"khaki": "#f0e68c",
"darkkhaki": "#bdb76b",
"lavender": "#e6e6fa",
"thistle": "#d8bfd8",
"plum": "#dda0dd",
"violet": "#ee82ee",
"orchid": "#da70d6",
"fuchsia": "#ff00ff",
"magenta": "#ff00ff",
"mediumorchid": "#ba55d3",
"mediumpurple": "#9370db",
"blueviolet": "#8a2be2",
"darkviolet": "#9400d3",
"darkorchid": "#9932cc",
"darkmagenta": "#8b008b",
"purple": "#800080",
"indigo": "#4b0082",
"darkslateblue": "#483d8b",
"slateblue": "#6a5acd",
"mediumslateblue": "#7b68ee",
"greenyellow": "#adff2f",
"chartreuse": "#7fff00",
"lawngreen": "#7cfc00",
"lime": "#00ff00",
"limegreen": "#32cd32",
"palegreen": "#98fb98",
"lightgreen": "#90ee90",
"mediumspringgreen": "#00fa9a",
"springgreen": "#00ff7f",
"mediumseagreen": "#3cb371",
"seagreen": "#2e8b57",
"forestgreen": "#228b22",
"green": "#008000",
"darkgreen": "#006400",
"yellowgreen": "#9acd32",
"olivedrab": "#6b8e23",
"olive": "#808000",
"darkolivegreen": "#556b2f",
"mediumaquamarine": "#66cdaa",
"darkseagreen": "#8fbc8f",
"lightseagreen": "#20b2aa",
"darkcyan": "#008b8b",
"teal": "#008080",
"aqua": "#00ffff",
"cyan": "#00ffff",
"lightcyan": "#e0ffff",
"paleturquoise": "#afeeee",
"aquamarine": "#7fffd4",
"turquoise": "#40e0d0",
"mediumturquoise": "#48d1cc",
"darkturquoise": "#00ced1",
"cadetblue": "#5f9ea0",
"steelblue": "#4682b4",
"lightsteelblue": "#b0c4de",
"powderblue": "#b0e0e6",
"lightblue": "#add8e6",
"skyblue": "#87ceeb",
"lightskyblue": "#87cefa",
"deepskyblue": "#00bfff",
"dodgerblue": "#1e90ff",
"cornflowerblue": "#6495ed",
"royalblue": "#4169e1",
"blue": "#0000ff",
"mediumblue": "#0000cd",
"darkblue": "#00008b",
"navy": "#000080",
"midnightblue": "#191970",
"cornsilk": "#fff8dc",
"blanchedalmond": "#ffebcd",
"bisque": "#ffe4c4",
"navajowhite": "#ffdead",
"wheat": "#f5deb3",
"burlywood": "#deb887",
"tan": "#d2b48c",
"rosybrown": "#bc8f8f",
"sandybrown": "#f4a460",
"goldenrod": "#daa520",
"darkgoldenrod": "#b8860b",
"peru": "#cd853f",
"chocolate": "#d2691e",
"saddlebrown": "#8b4513",
"sienna": "#a0522d",
"brown": "#a52a2a",
"maroon": "#800000",
"white": "#ffffff",
"snow": "#fffafa",
"honeydew": "#f0fff0",
"mintcream": "#f5fffa",
"azure": "#f0ffff",
"aliceblue": "#f0f8ff",
"ghostwhite": "#f8f8ff",
"whitesmoke": "#f5f5f5",
"seashell": "#fff5ee",
"beige": "#f5f5dc",
"oldlace": "#fdf5e6",
"floralwhite": "#fffaf0",
"ivory": "#fffff0",
"antiquewhite": "#faebd7",
"linen": "#faf0e6",
"lavenderblush": "#fff0f5",
"mistyrose": "#ffe4e1",
"gainsboro": "#dcdcdc",
"lightgrey": "#d3d3d3",
"silver": "#c0c0c0",
"darkgray": "#a9a9a9",
"gray": "#808080",
"dimgray": "#696969",
"lightslategray": "#778899",
"slategray": "#708090",
"darkslategray": "#2f4f4f",
"black": "#000000",
}
if os.name == "nt":
consoleColors = [
"#000000", #{ 0, 0, 0 },//0 - black
"#000080", #{ 0, 0, 128 },//1 - navy
"#008000", #{ 0, 128, 0 },//2 - green
"#008080", #{ 0, 128, 128 },//3 - teal
"#800000", #{ 128, 0, 0 },//4 - maroon
"#800080", #{ 128, 0, 128 },//5 - purple
"#808000", #{ 128, 128, 0 },//6 - olive
"#C0C0C0", #{ 192, 192, 192 },//7 - silver
"#808080", #{ 128, 128, 128 },//8 - gray
"#0000FF", #{ 0, 0, 255 },//9 - blue
"#00FF00", #{ 0, 255, 0 },//a - lime
"#00FFFF", #{ 0, 255, 255 },//b - cyan
"#FF0000", #{ 255, 0, 0 },//c - red
"#FF00FF", #{ 255, 0, 255 },//d - magenta
"#FFFF00", #{ 255, 255, 0 },//e - yellow
"#FFFFFF", #{ 255, 255, 255 } //f - white
]
else:
consoleColors = [
"#2e3436",
"#cc0000",
"#4e9a06",
"#c4a000",
"#3465a4",
"#75507b",
"#06989a",
"#d3d7cf",
"#ffffff",
"#555753",
"#ef2929",
"#8ae234",
"#fce94f",
"#729fcf",
"#ad7fa8",
"#34e2e2",
"#eeeeec",
]
def RGB2LAB(r,g,b):
if max(r,g,b):
r /= 255.
g /= 255.
b /= 255.
X = (0.412453 * r + 0.357580 * g + 0.180423 * b) / 0.950456
Y = (0.212671 * r + 0.715160 * g + 0.072169 * b)
Z = (0.019334 * r + 0.119193 * g + 0.950227 * b) / 1.088754
#[X * 0.950456] [0.412453 0.357580 0.180423] [R]
#[Y ] = [0.212671 0.715160 0.072169] * [G]
#[Z * 1.088754] [0.019334 0.119193 0.950227] [B]
T = 0.008856 #threshold
if X > T:
fX = math.pow(X, 1./3.)
else:
fX = 7.787 * X + 16./116.
# Compute L
if Y > T:
Y3 = math.pow(Y, 1./3.)
fY = Y3
L = 116. * Y3 - 16.0
else:
fY = 7.787 * Y + 16./116.
L = 903.3 * Y
if Z > T:
fZ = math.pow(Z, 1./3.)
else:
fZ = 7.787 * Z + 16./116.
# Compute a and b
a = 500. * (fX - fY)
b = 200. * (fY - fZ)
return (L,a,b)
def colorDistance(r1,g1,b1 = None, r2 = None, g2 = None,b2 = None):
if type(r1) == tuple and type(g1) == tuple and b1 is None and r2 is None and g2 is None and b2 is None:
(l1,a1,b1) = RGB2LAB(*r1)
(l2,a2,b2) = RGB2LAB(*g1)
else:
(l1,a1,b1) = RGB2LAB(r1,g1,b1)
(l2,a2,b2) = RGB2LAB(r2,g2,b2)
#CIE94
dl = l1-l2
C1 = math.sqrt(a1*a1 + b1*b1)
C2 = math.sqrt(a2*a2 + b2*b2)
dC = C1 - C2
da = a1-a2
db = b1-b2
dH = math.sqrt(max(0, da*da + db*db - dC*dC))
Kl = 1
K1 = 0.045
K2 = 0.015
s1 = dl/Kl
s2 = dC/(1. + K1 * C1)
s3 = dH/(1. + K2 * C1)
return math.sqrt(s1*s1 + s2*s2 + s3*s3)
def parseHexColor(col):
if len(col) != 4 and len(col) != 7 and not col.startswith("#"):
return (0,0,0)
if len(col) == 4:
r = col[1]*2
g = col[2]*2
b = col[3]*2
else:
r = col[1:3]
g = col[3:5]
b = col[5:7]
return (int(r,16), int(g,16), int(b,16))
def getColor(col):
if isinstance(col, str):
if col.lower() in webcolors:
return parseHexColor(webcolors[col.lower()])
else:
return parseHexColor(col)
else:
return col
def getNearestConsoleColor(col):
color = getColor(col)
minidx = 0
mindist = colorDistance(color, getColor(consoleColors[0]))
for i in range(len(consoleColors)):
dist = colorDistance(color, getColor(consoleColors[i]))
if dist < mindist:
mindist = dist
minidx = i
return minidx
if os.name == 'nt':
import msvcrt
from ctypes import windll, Structure, c_short, c_ushort, byref
SHORT = c_short
WORD = c_ushort
class COORD(Structure):
_fields_ = [
("X", SHORT),
("Y", SHORT)]
class SMALL_RECT(Structure):
_fields_ = [
("Left", SHORT),
("Top", SHORT),
("Right", SHORT),
("Bottom", SHORT)]
class CONSOLE_SCREEN_BUFFER_INFO(Structure):
_fields_ = [
("dwSize", COORD),
("dwCursorPosition", COORD),
("wAttributes", WORD),
("srWindow", SMALL_RECT),
("dwMaximumWindowSize", COORD)]
class winConsoleColorizer(object):
def __init__(self, stream):
self.handle = msvcrt.get_osfhandle(stream.fileno())
self.default_attrs = 7#self.get_text_attr()
self.stream = stream
def get_text_attr(self):
csbi = CONSOLE_SCREEN_BUFFER_INFO()
windll.kernel32.GetConsoleScreenBufferInfo(self.handle, byref(csbi))
return csbi.wAttributes
def set_text_attr(self, color):
windll.kernel32.SetConsoleTextAttribute(self.handle, color)
def write(self, *text, **attrs):
if not text:
return
color = attrs.get("color", None)
if color:
col = getNearestConsoleColor(color)
self.stream.flush()
self.set_text_attr(col)
self.stream.write(" ".join([str(t) for t in text]))
if color:
self.stream.flush()
self.set_text_attr(self.default_attrs)
class dummyColorizer(object):
def __init__(self, stream):
self.stream = stream
def write(self, *text, **attrs):
if text:
self.stream.write(" ".join([str(t) for t in text]))
class asciiSeqColorizer(object):
RESET_SEQ = "\033[0m"
#BOLD_SEQ = "\033[1m"
ITALIC_SEQ = "\033[3m"
UNDERLINE_SEQ = "\033[4m"
STRIKEOUT_SEQ = "\033[9m"
COLOR_SEQ0 = "\033[00;%dm" #dark
COLOR_SEQ1 = "\033[01;%dm" #bold and light
def __init__(self, stream):
self.stream = stream
def get_seq(self, code):
if code > 8:
return self.__class__.COLOR_SEQ1 % (30 + code - 9)
else:
return self.__class__.COLOR_SEQ0 % (30 + code)
def write(self, *text, **attrs):
if not text:
return
color = attrs.get("color", None)
if color:
col = getNearestConsoleColor(color)
self.stream.write(self.get_seq(col))
self.stream.write(" ".join([str(t) for t in text]))
if color:
self.stream.write(self.__class__.RESET_SEQ)
def getColorizer(stream):
if stream.isatty():
if os.name == "nt":
return winConsoleColorizer(stream)
else:
return asciiSeqColorizer(stream)
else:
return dummyColorizer(stream)

0
modules/ts/misc/concatlogs.py Normal file → Executable file
View File

14
modules/ts/misc/report.py Normal file → Executable file
View File

@@ -10,13 +10,13 @@ if __name__ == "__main__":
parser.add_option("-f", "--filter", dest="filter", help="regex to filter tests", metavar="REGEX", default=None)
parser.add_option("", "--show-all", action="store_true", dest="showall", default=False, help="also include empty and \"notrun\" lines")
(options, args) = parser.parse_args()
if len(args) < 1:
print >> sys.stderr, "Usage:\n", os.path.basename(sys.argv[0]), "<log_name1>.xml"
exit(0)
options.generateHtml = detectHtmlOutputType(options.format)
# expand wildcards and filter duplicates
files = []
files1 = []
@@ -44,8 +44,8 @@ if __name__ == "__main__":
if options.filter:
expr = re.compile(options.filter)
tests = [t for t in tests if expr.search(str(t))]
tests = [t for t in tests if expr.search(str(t))]
tbl = table(", ".join(files))
if options.columns:
metrics = [s.strip() for s in options.columns.split(",")]
@@ -56,14 +56,14 @@ if __name__ == "__main__":
metrics = ["name", "samples", "outliers", "min", "median", "gmean", "mean", "stddev"]
if "name" not in metrics:
metrics.insert(0, "name")
for m in metrics:
if m == "name":
tbl.newColumn(m, metrix_table[m][0])
else:
tbl.newColumn(m, metrix_table[m][0], align = "center")
needNewRow = True
needNewRow = True
for case in sorted(tests):
if needNewRow:
tbl.newRow()
@@ -88,7 +88,7 @@ if __name__ == "__main__":
tbl.newCell(m, val, val)
if not needNewRow:
tbl.trimLastRow()
# output table
if options.generateHtml:
if options.format == "moinwiki":

0
modules/ts/misc/run.py Normal file → Executable file
View File

24
modules/ts/misc/summary.py Normal file → Executable file
View File

@@ -26,7 +26,7 @@ if __name__ == "__main__":
if len(sys.argv) < 2:
print >> sys.stderr, "Usage:\n", os.path.basename(sys.argv[0]), "<log_name1>.xml [<log_name2>.xml ...]"
exit(0)
parser = OptionParser()
parser.add_option("-o", "--output", dest="format", help="output results in text format (can be 'txt', 'html' or 'auto' - default)", metavar="FMT", default="auto")
parser.add_option("-m", "--metric", dest="metric", help="output metric", metavar="NAME", default="gmean")
@@ -40,7 +40,7 @@ if __name__ == "__main__":
parser.add_option("", "--match", dest="match", default=None)
parser.add_option("", "--match-replace", dest="match_replace", default="")
(options, args) = parser.parse_args()
options.generateHtml = detectHtmlOutputType(options.format)
if options.metric not in metrix_table:
options.metric = "gmean"
@@ -49,7 +49,7 @@ if __name__ == "__main__":
options.calc_cr = False
if options.columns:
options.columns = [s.strip().replace("\\n", "\n") for s in options.columns.split(",")]
# expand wildcards and filter duplicates
files = []
seen = set()
@@ -62,7 +62,7 @@ if __name__ == "__main__":
fname = os.path.abspath(arg)
if fname not in seen and not seen.add(fname):
files.append(fname)
# read all passed files
test_sets = []
for arg in files:
@@ -79,20 +79,20 @@ if __name__ == "__main__":
sys.stderr.write("IOError reading \"" + arg + "\" - " + str(err) + os.linesep)
except xml.parsers.expat.ExpatError as err:
sys.stderr.write("ExpatError reading \"" + arg + "\" - " + str(err) + os.linesep)
if not test_sets:
sys.stderr.write("Error: no test data found" + os.linesep)
quit()
# find matches
setsCount = len(test_sets)
test_cases = {}
name_extractor = lambda name: str(name)
if options.match:
reg = re.compile(options.match)
name_extractor = lambda name: reg.sub(options.match_replace, str(name))
for i in range(setsCount):
for case in test_sets[i][1]:
name = name_extractor(case)
@@ -101,7 +101,7 @@ if __name__ == "__main__":
if name not in test_cases:
test_cases[name] = [None] * setsCount
test_cases[name][i] = case
# build table
getter = metrix_table[options.metric][1]
if options.calc_relatives:
@@ -109,7 +109,7 @@ if __name__ == "__main__":
if options.calc_cr:
getter_cr = metrix_table[options.metric + "$"][1]
tbl = table(metrix_table[options.metric][0])
# header
tbl.newColumn("name", "Name of Test", align = "left", cssclass = "col_name")
i = 0
@@ -127,7 +127,7 @@ if __name__ == "__main__":
for set in metric_sets:
tbl.newColumn(str(i) + "%", getSetName(set, i, options.columns) + "\nvs\n" + getSetName(test_sets[0], 0, options.columns) + "\n(x-factor)", align = "center", cssclass = "col_rel")
i += 1
# rows
prevGroupName = None
needNewRow = True
@@ -139,7 +139,7 @@ if __name__ == "__main__":
if not options.showall:
needNewRow = False
tbl.newCell("name", name)
groupName = next(c for c in cases if c).shortName()
if groupName != prevGroupName:
prop = lastRow.props.get("cssclass", "")

130
modules/ts/misc/table_formatter.py Normal file → Executable file
View File

@@ -13,12 +13,12 @@ class tblColumn(object):
self.text = caption
self.title = title
self.props = props
class tblRow(object):
def __init__(self, colsNum, props = None):
self.cells = [None] * colsNum
self.props = props
def htmlEncode(str):
return '<br/>'.join([cgi.escape(s) for s in str])
@@ -44,9 +44,9 @@ class table(object):
self.rows.append(tblRow(len(self.columns), properties))
else:
self.rows[ridx + 1].props = properties
self.ridx += 1
self.ridx += 1
return self.rows[self.ridx]
def trimLastRow(self):
if self.rows:
self.rows.pop()
@@ -90,24 +90,24 @@ class table(object):
cl = tblCell(text, value, properties)
row.cells[col.index] = cl
return cl
def layoutTable(self):
columns = self.columns.values()
columns.sort(key=lambda c: c.index)
colspanned = []
rowspanned = []
self.headerHeight = 1
rowsToAppend = 0
for col in columns:
self.measureCell(col)
if col.height > self.headerHeight:
self.headerHeight = col.height
col.minwidth = col.width
col.line = None
for r in range(len(self.rows)):
row = self.rows[r]
row.minheight = 1
@@ -141,12 +141,12 @@ class table(object):
self.rows[j].cells[i] = None
elif row.minheight < cell.height:
row.minheight = cell.height
self.ridx = len(self.rows) - 1
for r in range(rowsToAppend):
self.newRow()
self.rows[len(self.rows) - 1].minheight = 1
while colspanned:
colspanned_new = []
for r, c in colspanned:
@@ -169,7 +169,7 @@ class table(object):
addition = s * budget / total - spent
spent += addition
col.minwidth += addition
while rowspanned:
rowspanned_new = []
for r, c in rowspanned:
@@ -191,7 +191,7 @@ class table(object):
addition = s * budget / total - spent
spent += addition
row.minheight += addition
return columns
def measureCell(self, cell):
@@ -199,7 +199,7 @@ class table(object):
cell.text = self.reformatTextValue(text)
cell.height = len(cell.text)
cell.width = len(max(cell.text, key = lambda line: len(line)))
def reformatTextValue(self, value):
if isinstance(value, str):
vstr = value
@@ -211,7 +211,7 @@ class table(object):
except TypeError:
vstr = str(value)
return vstr.splitlines()
def adjustColWidth(self, cols, width):
total = sum([c.minWidth for c in cols])
if total + len(cols) - 1 >= width:
@@ -243,30 +243,30 @@ class table(object):
return getattr(self.__class__, "def_" + name)
except AttributeError:
return None
def consolePrintTable(self, out):
columns = self.layoutTable()
colrizer = getColorizer(out)
colrizer = getColorizer(out)
if self.caption:
out.write("%s%s%s" % ( os.linesep, os.linesep.join(self.reformatTextValue(self.caption)), os.linesep * 2))
headerRow = tblRow(len(columns), {"align": "center", "valign": "top", "bold": True, "header": True})
headerRow.cells = columns
headerRow.minheight = self.headerHeight
self.consolePrintRow2(colrizer, headerRow, columns)
for i in range(0, len(self.rows)):
self.consolePrintRow2(colrizer, i, columns)
def consolePrintRow2(self, out, r, columns):
if isinstance(r, tblRow):
row = r
r = -1
else:
row = self.rows[r]
#evaluate initial values for line numbers
i = 0
while i < len(row.cells):
@@ -284,7 +284,7 @@ class table(object):
for rw in rows:
rw.cells[i] = cell
i += colspan
#print content
for ln in range(row.minheight):
i = 0
@@ -300,7 +300,7 @@ class table(object):
self.consolePrintLine(cell, row, column, out)
i += self.getValue("colspan", cell)
out.write(os.linesep)
def consolePrintLine(self, cell, row, column, out):
if cell.line < 0 or cell.line >= cell.height:
line = ""
@@ -308,17 +308,17 @@ class table(object):
line = cell.text[cell.line]
width = cell.wspace
align = self.getValue("align", ((None, cell)[isinstance(cell, tblCell)]), row, column)
if align == "right":
pattern = "%" + str(width) + "s"
elif align == "center":
pattern = "%" + str((width - len(line)) / 2 + len(line)) + "s" + " " * (width - len(line) - (width - len(line)) / 2)
else:
pattern = "%-" + str(width) + "s"
out.write(pattern % line, color = self.getValue("color", cell, row, column))
cell.line += 1
def evalLine(self, cell, rows, column):
height = cell.height
valign = self.getValue("valign", cell, rows[0], column)
@@ -328,10 +328,10 @@ class table(object):
if valign == "middle":
return (height - space + 1) / 2
return 0
def htmlPrintTable(self, out, embeedcss = False):
columns = self.layoutTable()
if embeedcss:
out.write("<div style=\"font-family: Lucida Console, Courier New, Courier;font-size: 16px;color:#3e4758;\">\n<table style=\"background:none repeat scroll 0 0 #FFFFFF;border-collapse:collapse;font-family:'Lucida Sans Unicode','Lucida Grande',Sans-Serif;font-size:14px;margin:20px;text-align:left;width:480px;margin-left: auto;margin-right: auto;white-space:nowrap;\">\n")
else:
@@ -342,14 +342,14 @@ class table(object):
else:
out.write(" <caption>%s</caption>\n" % htmlEncode(self.reformatTextValue(self.caption)))
out.write(" <thead>\n")
headerRow = tblRow(len(columns), {"align": "center", "valign": "top", "bold": True, "header": True})
headerRow.cells = columns
header_rows = [headerRow]
header_rows.extend([row for row in self.rows if self.getValue("header")])
last_row = header_rows[len(header_rows) - 1]
for row in header_rows:
out.write(" <tr>\n")
for th in row.cells:
@@ -373,20 +373,20 @@ class table(object):
out.write(" %s\n" % htmlEncode(th.text))
out.write(" </th>\n")
out.write(" </tr>\n")
out.write(" </thead>\n <tbody>\n")
rows = [row for row in self.rows if not self.getValue("header")]
for r in range(len(rows)):
row = rows[r]
rowattr = ""
cssclass = self.getValue("cssclass", row)
if cssclass:
row = rows[r]
rowattr = ""
cssclass = self.getValue("cssclass", row)
if cssclass:
rowattr += " class=\"%s\"" % cssclass
out.write(" <tr%s>\n" % (rowattr))
i = 0
while i < len(row.cells):
column = columns[i]
column = columns[i]
td = row.cells[i]
if isinstance(td, int):
i += td
@@ -429,9 +429,9 @@ class table(object):
out.write(" </td>\n")
i += colspan
out.write(" </tr>\n")
out.write(" </tbody>\n</table>\n</div>\n")
def htmlPrintHeader(out, title = None):
if title:
titletag = "<title>%s</title>\n" % htmlEncode([str(title)])
@@ -450,7 +450,7 @@ html, body {font-family: Lucida Console, Courier New, Courier;font-size: 16px;co
.tbl th{border:none;color:#003399;font-size:16px;font-weight:normal;white-space:nowrap;padding:3px 10px;}
.tbl td{border:none;border-bottom:1px solid #CCCCCC;color:#666699;padding:6px 8px;white-space:nowrap;}
.tbl tbody tr:hover td{color:#000099;}
.tbl caption{font:italic 16px "Trebuchet MS",Verdana,Arial,Helvetica,sans-serif;padding:0 0 5px;text-align:right;white-space:normal;}
.tbl caption{font:italic 16px "Trebuchet MS",Verdana,Arial,Helvetica,sans-serif;padding:0 0 5px;text-align:right;white-space:normal;}
.firstingroup {border-top:2px solid #6678B1;}
</style>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
@@ -522,7 +522,7 @@ $(function(){
if (re.exec($(row.get(colIdx)).text()) == null)
return false
return pred(row)
}
}
} else if(flt.hasClass("filter_col_rel")) {
var percent = parseFloat(val)
if (percent < 0) {
@@ -531,14 +531,14 @@ $(function(){
if (!val || val >= 1 || val > 1+percent)
return false
return pred(row)
}
}
} else {
predicate = function(row) {
var val = parseFloat($(row.get(colIdx)).text())
if (!val || val < percent)
return false
return pred(row)
}
}
}
} else if(flt.hasClass("filter_col_cr")) {
var percent = parseFloat(val)
@@ -547,7 +547,7 @@ $(function(){
if (!val || val < percent)
return false
return pred(row)
}
}
}
}
});
@@ -567,10 +567,10 @@ $(function(){
</head>
<body>
""" % titletag)
def htmlPrintFooter(out):
out.write("</body>\n</html>")
def getStdoutFilename():
try:
if os.name == "nt":
@@ -584,7 +584,7 @@ def getStdoutFilename():
return os.readlink('/proc/self/fd/1')
except:
return ""
def detectHtmlOutputType(requestedType):
if requestedType == "txt":
return False
@@ -601,8 +601,8 @@ def detectHtmlOutputType(requestedType):
else:
return False
else:
return False
return False
def getRelativeVal(test, test0, metric):
if not test or not test0:
return None
@@ -625,21 +625,21 @@ def getCycleReduction(test, test0, metric):
return None
return (1.0-float(val)/val0)*100
metrix_table = \
{
"name": ("Name of Test", lambda test,test0,units: str(test)),
"samples": ("Number of\ncollected samples", lambda test,test0,units: test.get("samples", units)),
"outliers": ("Number of\noutliers", lambda test,test0,units: test.get("outliers", units)),
"gmean": ("Geometric mean", lambda test,test0,units: test.get("gmean", units)),
"mean": ("Mean", lambda test,test0,units: test.get("mean", units)),
"min": ("Min", lambda test,test0,units: test.get("min", units)),
"median": ("Median", lambda test,test0,units: test.get("median", units)),
"stddev": ("Standard deviation", lambda test,test0,units: test.get("stddev", units)),
"gstddev": ("Standard deviation of Ln(time)", lambda test,test0,units: test.get("gstddev")),
"gmean%": ("Geometric mean (relative)", lambda test,test0,units: getRelativeVal(test, test0, "gmean")),
"mean%": ("Mean (relative)", lambda test,test0,units: getRelativeVal(test, test0, "mean")),
"min%": ("Min (relative)", lambda test,test0,units: getRelativeVal(test, test0, "min")),
@@ -668,17 +668,17 @@ if __name__ == "__main__":
if len(sys.argv) < 2:
print "Usage:\n", os.path.basename(sys.argv[0]), "<log_name>.xml"
exit(0)
parser = OptionParser()
parser.add_option("-o", "--output", dest="format", help="output results in text format (can be 'txt', 'html' or 'auto' - default)", metavar="FMT", default="auto")
parser.add_option("-m", "--metric", dest="metric", help="output metric", metavar="NAME", default="gmean")
parser.add_option("-u", "--units", dest="units", help="units for output values (s, ms (default), mks, ns or ticks)", metavar="UNITS", default="ms")
(options, args) = parser.parse_args()
options.generateHtml = detectHtmlOutputType(options.format)
if options.metric not in metrix_table:
options.metric = "gmean"
#print options
#print args
@@ -711,10 +711,10 @@ if __name__ == "__main__":
# htmlPrintFooter(sys.stdout)
import testlog_parser
if options.generateHtml:
htmlPrintHeader(sys.stdout, "Tables demo")
getter = metrix_table[options.metric][1]
for arg in args:
@@ -722,11 +722,11 @@ if __name__ == "__main__":
tbl = table(arg)
tbl.newColumn("name", "Name of Test", align = "left")
tbl.newColumn("value", metrix_table[options.metric][0], align = "center", bold = "true")
for t in sorted(tests):
tbl.newRow()
tbl.newCell("name", str(t))
status = t.get("status")
if status != "run":
tbl.newCell("value", status)
@@ -739,11 +739,11 @@ if __name__ == "__main__":
tbl.newCell("value", "%.3f %s" % (val, options.units), val)
else:
tbl.newCell("value", "-")
if options.generateHtml:
tbl.htmlPrintTable(sys.stdout)
else:
tbl.consolePrintTable(sys.stdout)
if options.generateHtml:
htmlPrintFooter(sys.stdout)

4
modules/ts/misc/testlog_parser.py Normal file → Executable file
View File

@@ -28,7 +28,7 @@ class TestInfo(object):
self.parseLongMetric(xmlnode, "mean");
self.parseLongMetric(xmlnode, "stddev");
self.parseFloatMetric(xmlnode, "gstddev");
def parseLongMetric(self, xmlnode, name, default = 0):
if xmlnode.hasAttribute(name):
tmp = xmlnode.getAttribute(name)
@@ -94,7 +94,7 @@ class TestInfo(object):
def dump(self, units="ms"):
print "%s ->\t\033[1;31m%s\033[0m = \t%.2f%s" % (str(self), self.status, self.get("gmean", units), units)
def shortName(self):
pos = self.name.find("/")
if pos > 0:

View File

@@ -57,7 +57,7 @@ ArrayTest::ArrayTest()
min_log_array_size = 0;
max_log_array_size = default_max_log_array_size;
element_wise_relative_error = true;
test_array.resize(MAX_ARR);
}
@@ -325,9 +325,9 @@ int ArrayTest::validate_test_results( int test_case_idx )
continue;
}
string idxstr = vec2str(", ", &idx[0], idx.size());
ts->printf( TS::LOG, "%s in %s array %d at (%s)", msg, arr_names[i0], j, idxstr.c_str() );
for( i0 = 0; i0 < (int)test_array.size(); i0++ )
{
size_t sizei0 = test_array[i0].size();
@@ -352,7 +352,7 @@ int ArrayTest::validate_test_results( int test_case_idx )
return 0;
}
}
/* End of file. */

View File

@@ -7221,7 +7221,7 @@ void StackLowerThanAddress(const void* ptr, bool* result) {
*result = (&dummy < ptr);
}
#if GTEST_HAS_CLONE
#if GTEST_HAS_CLONE
static bool StackGrowsDown() {
int dummy;
bool result;

View File

@@ -579,7 +579,7 @@ Regression& Regression::operator() (const std::string& name, cv::InputArray arra
#ifdef HAVE_CUDA
static const std::string prefix = (param_run_cpu)? "CPU_" : "GPU_";
if(suiteName == "gpu")
nodename = prefix + nodename;
nodename = prefix + nodename;
#endif
cv::FileNode n = rootIn[nodename];