Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!gem.mps.ohio-state.edu!ginosko!uunet!zephyr.ens.tek.com!orca!shark!adamsc From: adamsc@shark.WV.TEK.COM (Chuck Adams) Newsgroups: comp.windows.x Subject: Problems with XSTONES calculations in xbench Keywords: X11, Graphics, Performance Message-ID: <4344@orca.WV.TEK.COM> Date: 25 Aug 89 17:37:43 GMT Sender: nobody@orca.WV.TEK.COM Lines: 398 About two weeks ago I tried to contact Claus Gittinger with the following concerns I have about the XSTONES calculations in xbench. Because I have concerns that someone may be using this program I will post this mail awaiting an answer from Claus. --- chuck adams adamsc@orca.wv.tek.com {decvax ucbvax hplabs}!tektronix!orca!adamsc Interactive Technologies Division/Visual Systems Group Tektronix, Inc. P.O. Box 1000, M/S 61-049 Wilsonville, OR 97070 (503) 685-2589 ------------------------------------------------------------------------------ To: sinix!claus@unido.UUCP Cc: adamsc Subject: Problems with XSTONES calculations in xbench I have been using the xbench program and have a fairly major problem with the algorithm used to compute xstones. I believe the file xstones.awk is incorrect in the following way. The current algorithm uses the following mathematics: ratio_n = measured_value / sun_value ratio_w = sum of (weight x sun_value / measured_value) k x sum of (weight x sun_value / measured_value) ratio_w = ------------------------------------------------ sum of (weight) k ratio_w = ------------------------------------------------------------------------ k x (k x sum of (weight x sun_value / measured_value)) / sum of (weight) k x sum of (weight) ratio_w = --------------------------------------------- sum of (weight x sun_value / measured_value)) The algorithm should be changed to use the following mathematics: ratio_n = measured_value / sun_value ratio_w = sum of (weight x measured_value / sun_value) k x sum of (weight x measured_value / sun_value) ratio_w = ------------------------------------------------ sum of (weight) In theory the more something is weighted the more it should affect the xstone calculated. I believe the following test cases indicate the nature of the problem: Test case a: measured_value[0] = 100 weight[0] = 300 sun_value[0] = 100 measured_value[1] = 10 weight[1] = 600 sun_value[1] = 10 xstone by old algorithm = 10000 xstone should be = 10000 Test case b: measured_value[0] = 50 weight[0] = 300 sun_value[0] = 100 measured_value[1] = 20 weight[1] = 600 sun_value[1] = 10 xstone by old algorithm = 10000 xstone should be = 15000 Test case c: measured_value[0] = 100 weight[0] = 300 sun_value[0] = 100 measured_value[1] = 20 weight[1] = 600 sun_value[1] = 10 xstone by old algorithm = 15000 xstone should be = 16666 A diagram of the correct results for these three test cases would be: case a case b case c xstone 10000 15000 16666 __ __ | | | | | | | | | | | | | | | | | | | | __ | | | | | | | | | | | | | | | | | | | | | | | | | | | | weight | | | | | | 600 | | | | | | ---- ---- ---- weight | | | | | | 300 | | ---- | | |__| |__| The context diffs at the end of this message should fix the problem. If you have any questions please contact me at your earliest convenience. Thanks for your help. ---- chuck adams *** xstones.awk Fri Aug 11 13:59:23 1989 --- xstones.awk.orig Fri Aug 11 12:38:41 1989 *************** *** 128,134 /rate =/ { if ( x != "dummy" ) { ratio = $3 / sunValue[x]; ! runtime["all"] = runtime["all"] + w*ratio; countedWeight["all"] = countedWeight["all"] + w; runtime[g] = runtime[g] + w*ratio; --- 128,134 ----- /rate =/ { if ( x != "dummy" ) { ratio = $3 / sunValue[x]; ! runtime["all"] = runtime["all"] + w/ratio; countedWeight["all"] = countedWeight["all"] + w; runtime[g] = runtime[g] + w/ratio; *************** *** 131,137 runtime["all"] = runtime["all"] + w*ratio; countedWeight["all"] = countedWeight["all"] + w; ! runtime[g] = runtime[g] + w*ratio; countedWeight[g] = countedWeight[g] + w; x = "dummy"; w = 1 } --- 131,137 ----- runtime["all"] = runtime["all"] + w/ratio; countedWeight["all"] = countedWeight["all"] + w; ! runtime[g] = runtime[g] + w/ratio; countedWeight[g] = countedWeight[g] + w; x = "dummy"; w = 1 } *************** *** 154,159 if (cw == 0) { print "TOTAL ? lineStones" } else { if (mw > 0) { text = "expected "; } else { --- 154,160 ----- if (cw == 0) { print "TOTAL ? lineStones" } else { + rt = (rt*allWeight)/cw; if (mw > 0) { text = "expected "; } else { *************** *** 160,166 text = ""; } ! ratio = rt / cw; stones = int(allWeight * ratio); t = sprintf("TOTAL %s %8.0f lineStones",text,stones); print t; --- 161,167 ----- text = ""; } ! ratio = allWeight/rt; stones = int(allWeight * ratio); t = sprintf("TOTAL %s %8.0f lineStones",text,stones); print t; *************** *** 173,178 if (cw == 0) { print "TOTAL ? fillStones" } else { if (mw > 0) { text = "expected "; } else { --- 174,180 ----- if (cw == 0) { print "TOTAL ? fillStones" } else { + rt = (rt*allWeight)/cw; if (mw > 0) { text = "expected "; } else { *************** *** 179,185 text = ""; } ! ratio = rt / cw; stones = int(allWeight * ratio); t = sprintf("TOTAL %s %8.0f fillStones",text,stones); print t; --- 181,187 ----- text = ""; } ! ratio = allWeight/rt; stones = int(allWeight * ratio); t = sprintf("TOTAL %s %8.0f fillStones",text,stones); print t; *************** *** 192,197 if (cw == 0) { print "TOTAL ? blitStones" } else { if (mw > 0) { text = "expected "; } else { --- 194,200 ----- if (cw == 0) { print "TOTAL ? blitStones" } else { + rt = (rt*allWeight)/cw; if (mw > 0) { text = "expected "; } else { *************** *** 198,204 text = ""; } ! ratio = rt / cw; stones = int(allWeight * ratio); t = sprintf("TOTAL %s %8.0f blitStones",text,stones); print t; --- 201,207 ----- text = ""; } ! ratio = allWeight/rt; stones = int(allWeight * ratio); t = sprintf("TOTAL %s %8.0f blitStones",text,stones); print t; *************** *** 211,216 if (cw == 0) { print "TOTAL ? arcStones" } else { if (mw > 0) { text = "expected "; } else { --- 214,220 ----- if (cw == 0) { print "TOTAL ? arcStones" } else { + rt = (rt*allWeight)/cw; if (mw > 0) { text = "expected "; } else { *************** *** 217,223 text = ""; } ! ratio = rt / cw; stones = int(allWeight * ratio); t = sprintf("TOTAL %s %8.0f arcStones",text,stones); print t; --- 221,227 ----- text = ""; } ! ratio = allWeight/rt; stones = int(allWeight * ratio); t = sprintf("TOTAL %s %8.0f arcStones",text,stones); print t; *************** *** 230,235 if (cw == 0) { print "TOTAL ? textStones" } else { if (mw > 0) { text = "expected "; } else { --- 234,240 ----- if (cw == 0) { print "TOTAL ? textStones" } else { + rt = (rt*allWeight)/cw; if (mw > 0) { text = "expected "; } else { *************** *** 236,242 text = ""; } ! ratio = rt / cw; stones = int(allWeight * ratio); t = sprintf("TOTAL %s %8.0f textStones",text,stones); print t; --- 241,247 ----- text = ""; } ! ratio = allWeight/rt; stones = int(allWeight * ratio); t = sprintf("TOTAL %s %8.0f textStones",text,stones); print t; *************** *** 249,254 if (cw == 0) { print "TOTAL ? complexStones" } else { if (mw > 0) { text = "expected "; } else { --- 254,260 ----- if (cw == 0) { print "TOTAL ? complexStones" } else { + rt = (rt*allWeight)/cw; if (mw > 0) { text = "expected "; } else { *************** *** 255,261 text = ""; } ! ratio = rt / cw; stones = int(allWeight * ratio); t = sprintf("TOTAL %s %8.0f complexStones",text,stones); print t; --- 261,267 ----- text = ""; } ! ratio = allWeight/rt; stones = int(allWeight * ratio); t = sprintf("TOTAL %s %8.0f complexStones",text,stones); print t; *************** *** 268,273 if (cw == 0) { print "TOTAL ? xStones" } else { if (mw > 0) { text = "expected "; } else { --- 274,280 ----- if (cw == 0) { print "TOTAL ? xStones" } else { + rt = (rt*allWeight)/cw; if (mw > 0) { text = "expected "; } else { *************** *** 274,280 text = ""; } ! ratio = rt / cw; stones = int(allWeight * ratio); t = sprintf("TOTAL %s %8.0f xStones",text,stones); print t; --- 281,287 ----- text = ""; } ! ratio = allWeight/rt; stones = int(allWeight * ratio); t = sprintf("TOTAL %s %8.0f xStones",text,stones); print t; -------