not part of build, test UI.

XUL interface for xsltmark, http://www.datapower.com/XSLTMark/.
Joint work with peterv, thanx for the work.
I tried to clean his stuff up, and make it non-block. I succeeded in the latter. I'm not happy with the UI yet, but that may come later.


git-svn-id: svn://10.0.0.236/trunk@124705 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
axel%pike.org 2002-07-05 12:36:13 +00:00
parent 6fb70f9b1d
commit 5dbe8dcceb
5 changed files with 459 additions and 0 deletions

View File

@ -0,0 +1,77 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is TransforMiiX XSLT Processor.
*
* The Initial Developer of the Original Code is
* Axel Hecht.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Axel Hecht <axel@pike.org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
const enablePrivilege = netscape.security.PrivilegeManager.enablePrivilege;
const IOSERVICE_CTRID = "@mozilla.org/network/io-service;1";
const nsIIOService = Components.interfaces.nsIIOService;
const SIS_CTRID = "@mozilla.org/scriptableinputstream;1";
const nsISIS = Components.interfaces.nsIScriptableInputStream;
const nsIFilePicker = Components.interfaces.nsIFilePicker;
const STDURL_CTRID = "@mozilla.org/network/standard-url;1";
const nsIURI = Components.interfaces.nsIURI;
var gStop = false;
function loadFile(aUriSpec)
{
enablePrivilege('UniversalXPConnect');
var serv = Components.classes[IOSERVICE_CTRID].
getService(nsIIOService);
if (!serv) {
throw Components.results.ERR_FAILURE;
}
var chan = serv.newChannel(aUriSpec, null, null);
var instream =
Components.classes[SIS_CTRID].createInstance(nsISIS);
instream.init(chan.open());
return instream.read(instream.available());
}
function dump20(aVal)
{
const pads = ' ';
if (typeof(aVal)=='string')
out = aVal;
else if (typeof(aVal)=='number')
out = Number(aVal).toFixed(2);
else
out = new String(aVal);
dump(pads.substring(0, 20 - out.length));
dump(out);
}

View File

@ -0,0 +1,79 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is TransforMiiX XSLT Processor.
*
* The Initial Developer of the Original Code is
* Axel Hecht.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Axel Hecht <axel@pike.org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
var gParser = new DOMParser;
var gProc = new XSLTProcessor;
var gTimeout;
function Test(aTitle, aSourceURL, aStyleURL, aNumber, aObserver)
{
this.mTitle = aTitle;
this.mObserver = aObserver;
this.mTotal = aNumber;
this.mDone = 0;
var xmlcontent = loadFile(aSourceURL);
var xslcontent = loadFile(aStyleURL);
this.mSource = gParser.parseFromString(xmlcontent, 'text/xml');
this.mStyle = gParser.parseFromString(xslcontent, 'text/xml');
}
function runTest(aTitle, aSourceURL, aStyleURL, aNumber, aObserver)
{
test = new Test(aTitle, aSourceURL, aStyleURL, aNumber,
aObserver);
gTimeout = setTimeout(onNextTransform, 100, test, 0);
}
function onNextTransform(aTest, aNumber)
{
res = document.implementation.createDocument('', '', null);
var startTime = Date.now();
gProc.transformDocument(aTest.mSource, aTest.mStyle, res, null);
var endTime = Date.now();
aNumber++;
var progress = aNumber / aTest.mTotal * 100;
if (aTest.mObserver) {
aTest.mObserver.progress(aTest.mTitle, endTime - startTime,
progress);
}
if (aNumber < aTest.mTotal) {
gTimeout = setTimeout(onNextTransform, 100, aTest, aNumber);
} else if (aTest.mObserver) {
aTest.mObserver.done(aTest.mTitle);
}
}

View File

@ -0,0 +1,208 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is TransforMiiX XSLT Processor.
*
* The Initial Developer of the Original Code is
* Axel Hecht.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Axel Hecht <axel@pike.org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
var view =
{
configUrl: null,
testArray: null,
mCurrent: null,
browseForConfig: function()
{
enablePrivilege('UniversalXPConnect');
var fp = Components.classes["@mozilla.org/filepicker;1"].
createInstance(nsIFilePicker);
fp.init(window,'XSLTMark Description File',nsIFilePicker.modeOpen);
fp.appendFilter('*.conf', '*.conf');
fp.appendFilters(nsIFilePicker.filterAll);
var res = fp.show();
if (res == nsIFilePicker.returnOK) {
this.configUrl = Components.classes[STDURL_CTRID].createInstance(nsIURI);
this.configUrl.spec = fp.fileURL.spec;
document.getElementById('config').setAttribute('value', this.configUrl.spec);
}
this.parseConfig();
return true;
},
parseConfig: function()
{
this.testArray = new Array();
var test;
if (!this.configUrl) {
return;
}
var content = loadFile(this.configUrl.spec);
var lines = content.split("\n");
var line, res;
var head = /^\[(.+)\]$/;
var instruct = /^(.+)=(.+)$/;
while (lines.length) {
line = lines.shift();
if (head.test(line)) {
test = new Object;
res = head.exec(line);
test['title'] = res[1];
this.testArray.push(test);
}
else if (line == '') {
test = undefined;
}
else {
res = instruct.exec(line);
test[res[1]] = res[2];
}
}
},
onLoad: function()
{
this.mCurrentStatus = document.getElementById('currentStatus');
this.mCurrentProgress = document.getElementById('currentProgress');
this.mTotalProgress = document.getElementById('totalProgress');
this.mOutput = document.getElementById('transformOutput');
this.mDetailOutput =
document.getElementById('transformDetailedOutput');
this.mDetail = true;
},
progress: function(aTitle, aTime, aProgress)
{
// dump20(aTitle);
// dump20(aTime);
// dump20(aProgress);
this.mCurrentProgress.value = aProgress;
this.displayDetailTime(aTime);
this.mTimes.push(aTime);
// dump("\n");
},
done: function(aTitle)
{
// dump(aTitle + " is finished.\n");
this.mCurrent++;
this.mCurrentProgress.value = 0;
this.displayTotalTime();
if (this.mCurrent >= this.testArray.length) {
this.mTotalProgress.value = 0;
this.mCurrentStatus.value = "done";
return;
}
this.mTotalProgress.value = this.mCurrent*100/this.testArray.length;
var test = this.testArray[this.mCurrent];
enablePrivilege('UniversalXPConnect');
this.displayTest(test.title);
runTest(test.title, this.configUrl.resolve(test.input),
this.configUrl.resolve(test.stylesheet),
test.iterations, this);
},
onStop: function()
{
clearTimeout(gTimeout);
this.mCurrentProgress.value = 0;
this.mTotalProgress.value = 0;
this.mCurrentStatus.value = "stopped";
},
displayTest: function(aTitle)
{
this.mTimes = new Array;
aTitle += "\t";
this.mCurrentStatus.value = aTitle;
this.mOutput.value += aTitle;
if (this.mDetail) {
this.mDetailOutput.value += aTitle;
}
},
displayDetailTime: function(aTime)
{
if (this.mDetail) {
this.mDetailOutput.value += aTime + " ms\t";
}
},
displayTotalTime: function()
{
var sum = 0;
for (k = 0; k < this.mTimes.length; k++) {
sum += this.mTimes[k];
}
var mean = sum / this.mTimes.length;
this.mOutput.value += Number(mean).toFixed(2) + " ms\t" + sum + " ms\t";
var variance = 0;
for (k = 0; k < this.mTimes.length; k++) {
var n = this.mTimes[k] - mean;
variance += n*n;
}
variance = Math.sqrt(variance/this.mTimes.length);
this.mOutput.value += Number(variance).toFixed(2)+"\n";
if (this.mDetail) {
this.mDetailOutput.value += "\n";
}
},
runBenchmark: function()
{
enablePrivilege('UniversalXPConnect');
if (!this.testArray) {
if (!this.configUrl) {
this.configUrl = Components.classes[STDURL_CTRID].createInstance(nsIURI);
this.configUrl.spec = document.getElementById('config').value;
}
this.parseConfig();
}
this.mCurrent = 0;
var test = this.testArray[this.mCurrent];
this.mOutput.value = '';
if (this.mDetail) {
this.mDetailOutput.value = '';
}
this.displayTest(test.title);
runTest(test.title, this.configUrl.resolve(test.input),
this.configUrl.resolve(test.stylesheet),
test.iterations, this);
return true;
}
}

View File

@ -0,0 +1,25 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Axel Hecht.
* Portions created by Axel Hecht are Copyright (C) 2002 Axel Hecht.
* All Rights Reserved.
*
* Contributor(s):
* Axel Hecht <axel@pike.org> (Original Author)
*/
textbox.out {
white-space: pre;
}

View File

@ -0,0 +1,70 @@
<?xml version="1.0"?>
<!--
The contents of this file are subject to the Mozilla Public
License Version 1.1 (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.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
The Original Code is mozilla.org.
The Initial Developer of the Original Code is Axel Hecht.
Portions created by Axel Hecht are Copyright (C) 2002 Axel Hecht.
All Rights Reserved.
Contributor(s):
Axel Hecht <axel@pike.org> (Original Author)
-->
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
<?xml-stylesheet href="XSLTMark.css" type="text/css"?>
<window id="XSLTMarkHarness"
title="XSLTMark"
onload="view.onLoad()"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
orient="vertical">
<script type="application/x-javascript" src="XSLTMark-static.js" />
<script type="application/x-javascript" src="XSLTMark-test.js" />
<script type="application/x-javascript" src="XSLTMark-view.js" />
<hbox>
<groupbox orient="horizontal">
<caption label="test description file" />
<label value=""/><!-- needed, otherwise groupbox fucks up :-( -->
<textbox id="config" persist="value" readonly="true"/>
<button label="browse..." oncommand="view.browseForConfig();" />
</groupbox>
<groupbox orient="horizontal">
<caption label="test control" />
<button label="run..."
oncommand="setTimeout('view.runBenchmark();', 0);" />
<button label="stop" oncommand="view.onStop();" />
</groupbox>
<groupbox orient="horizontal">
<caption label="options" />
<label value="responsiveness: "/>
<menulist label="sloppy">
<menupopup>
<menuitem label="sloppy" selected="true"/>
<menuitem label="bad"/>
</menupopup>
</menulist>
</groupbox>
</hbox>
<hbox>
<textbox id="currentStatus" readonly="true" flex="1"/>
<progressmeter id="currentProgress" mode="normal" value="0" flex="2"/>
<progressmeter id="totalProgress" mode="normal" value="0" flex="2"/>
</hbox>
<hbox flex="1">
<textbox id="transformOutput" class="out" readonly="true" multiline="true" flex="1"/>
</hbox>
<hbox flex="1">
<textbox id="transformDetailedOutput" class="out" readonly="true" multiline="true" flex="1"/>
</hbox>
</window>