|
From: <pm_...@us...> - 2011-08-17 14:00:04
|
Revision: 4436
http://mxquery.svn.sourceforge.net/mxquery/?rev=4436&view=rev
Author: pm_fischer
Date: 2011-08-17 13:59:55 +0000 (Wed, 17 Aug 2011)
Log Message:
-----------
Ghislain's test cases
Added Paths:
-----------
trunk/MXQuery/aggregate2.xquery
trunk/MXQuery/notm.xml
trunk/MXQuery/tm.xml
Added: trunk/MXQuery/aggregate2.xquery
===================================================================
--- trunk/MXQuery/aggregate2.xquery (rev 0)
+++ trunk/MXQuery/aggregate2.xquery 2011-08-17 13:59:55 UTC (rev 4436)
@@ -0,0 +1,162 @@
+declare variable $tmfiles external;
+declare variable $notmfiles external;
+
+(: declare variable $tmfile as document-node() external;
+declare variable $notmfile as document-node() external; :)
+
+declare function local:read-files($files)
+{
+ <contents>
+ {
+ for $name in $files/files/file
+ return <content>{doc($name)/measurements}</content>
+ }
+ </contents>
+};
+
+declare function local:get-kinds()
+{
+ doc($tmfiles/files/file[1])/measurements/kind/data(@name)
+};
+
+
+declare function local:extract-x-axis-for-kind($kind)
+{
+ doc($tmfiles/files/file[1])/measurements/kind[@name=$kind]/values/value/data(version)
+};
+
+declare function local:normalize-kind($file, $kind, $x-axis)
+{
+ let $f := doc($file)/measurements/kind[@name=$kind]
+ return
+ <kind name="{$kind}">
+ <average>{$f/data(average)}</average>
+ <values>
+ {
+ for $v in $x-axis
+ return <value>
+ <version>{$v}</version>
+ <time>{
+ let $nv := $f/values/value[xs:integer(version) le xs:integer($v)][last()]
+ (: adding or removing [last()] on the line above changes the number of elements outputs in the FLWOR! :)
+ return
+ if ($nv) then data($nv[last()]/time) else data($f/values/value[last()]/time)
+
+ }</time>
+ </value>
+ }
+ </values>
+ </kind>
+};
+
+declare function local:compute-average($files, $kind, $x-axis)
+{
+ let $normalized-contents := for $f in $files return local:normalize-kind($f, $kind, $x-axis)
+ return
+ <kind name="{$kind}">
+ <average>{avg($normalized-contents/data(average))}</average>
+ <values>
+ {
+ for $v in $x-axis
+ return <value>
+ <version>{$v}</version>
+ <time>{
+ avg($normalized-contents/values/value[version=$v]/time)
+ }</time>
+ </value>
+ }
+ </values>
+ </kind>
+};
+
+ for $kind in "insert1"
+ let $x-axis := local:extract-x-axis-for-kind($kind)
+ let $kind-notm := local:normalize-kind($notmfiles/files/file[1],
+ $kind,
+ $x-axis)
+ return $kind-notm
+(: <html>
+ <head>
+ <meta charset="utf-8"/>
+ <style>
+ body {{font-family:Arial}}
+ div#id-display {{}}
+ span.version {{background-color:gray;color:white;width:100%;display:block}}
+ span.content {{display:block}}
+ ul.listing li {{list-style:none;border-bottom:solid 1px}}
+ ul.listing {{margin:0px;padding:0px}}
+ span.element {{color:blue}}
+ span.attribute {{color:red}}
+ span.text {{color:black}}
+ span.comment {{color:purple}}
+ span.reference {{font-size:6pt;color:gray}}
+ span.pi {{color:green}}
+ hr.document-separator {{border: 1px dashed gray}}
+ .error {{color:red}}
+ .tree-id {{font-size: 18pt; color: green}}
+ .ordpath {{font-size: 18pt; color: red}}
+ .version-id {{font-size: 18pt; color: blue}}
+ .selected {{background-color: yellow}}
+ .doselect {{color: black}}
+ .isselected {{color: green;text-weight: bold}}
+ .invisible {{display: none}}
+ .selectable {{cursor: pointer}}
+ </style>
+ <script type="text/javascript" src="https://www.google.com/jsapi"></script>
+ {
+ for $kind in local:get-kinds()
+ let $kind-tm := local:compute-average($tmfiles/files/file,
+ $kind,
+ local:extract-x-axis-for-kind($kind))
+ let $kind-notm := local:compute-average($notmfiles/files/file,
+ $kind,
+ local:extract-x-axis-for-kind($kind))
+ return
+ <script type="text/javascript">
+ google.load("visualization", "1", {{packages:["corechart"]}});
+ google.setOnLoadCallback(drawChart);
+ function drawChart() {{
+ var data = new google.visualization.DataTable();
+ data.addColumn('string', '# Versions');
+ data.addColumn('number', 'Time Travel');
+ data.addColumn('number', 'No time travel');
+ data.addRows({count($kind-tm/values/value)});
+ {
+ for $t at $p in $kind-tm/values/value
+ let $t-notm := $kind-notm/values/value[version eq $t/version]
+ return
+ <dummy>data.setValue({$p - 1}, 0, '{$t/data(version)}');data.setValue({$p - 1}, 1, {$t/data(time)});data.setValue({$p - 1}, 2, {$t-notm/data(time)});</dummy>/data(.)
+ }
+ var chart = new google.visualization.LineChart(document.getElementById('chart_div_{$kind-tm/data(@name)}'));
+ chart.draw(data, {{width: 800, height: 240, title: 'y = execution time (ms) for the x-th execution of query {$kind-tm/data(@name)}'}});
+ }}
+ </script>
+ }
+ </head>
+ <body>
+ <div>
+ <h1>Measurement summary</h1>
+ {
+ for $kind in local:get-kinds()
+ let $kind-tm := local:compute-average($tmfiles/files/file,
+ $kind,
+ local:extract-x-axis-for-kind($kind))
+ let $kind-notm := local:compute-average($notmfiles/files/file,
+ $kind,
+ local:extract-x-axis-for-kind($kind))
+ return
+ let $average-time-tm := $kind-tm/data(average)
+ let $average-time-notm := $kind-notm/data(average)
+ let $standard-deviation-time-tm := math:sqrt(avg($kind-tm/values/value/math:pow(time - $average-time-tm, 2)))
+ let $standard-deviation-time-notm := math:sqrt(avg($kind-notm/values/value/math:pow(time - $average-time-notm,2)))
+ return
+ <div>
+ <h2>Kind: {$kind-tm/data(@name)}</h2>
+ <p>Execution time with time travel-enabled Sausalito: average {round($average-time-tm)} +/- {round($standard-deviation-time-tm)} ms</p>
+ <p>Execution time in original Sausalito: average {round($average-time-notm)} +/- {round($standard-deviation-time-notm)} ms</p>
+ <div id="chart_div_{$kind-tm/data(@name)}"/>
+ </div>
+ }
+ </div>
+ </body>
+ </html> :)
\ No newline at end of file
Added: trunk/MXQuery/notm.xml
===================================================================
--- trunk/MXQuery/notm.xml (rev 0)
+++ trunk/MXQuery/notm.xml 2011-08-17 13:59:55 UTC (rev 4436)
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|