not part of build. Fix stats and output datasources. Don't work on the database, but on the separate datasources, have a in-memory ds for each. Speedup by removing the datasource observer.

This commit is contained in:
axel%pike.org 2002-09-25 20:23:23 +00:00
Родитель d276f365a4
Коммит 0d9b9b6785
5 изменённых файлов: 98 добавлений и 144 удалений

Просмотреть файл

@ -70,7 +70,7 @@ var cmdFileController =
this.content += aContent;
return aCount;
};
serial.init(view.memoryDataSource);
serial.init(view.mResultDS);
serial.QueryInterface(nsIRDFXMLSource);
serial.Serialize(sink);
if (!sink.content.length) {
@ -103,14 +103,12 @@ var cmdFileController =
if (res == nsIFilePicker.returnOK) {
var fl = fp.file;
if (view.previousResults) {
view.database.RemoveDataSource(view.previousResults);
view.previousResults = null;
if (view.mPreviousResultDS) {
view.database.RemoveDataSource(view.mPreviousResultDS);
view.mPreviousResultDS = null;
}
view.database.RemoveDataSource(view.memoryDataSource);
view.previousResults = kRDFSvc.GetDataSource(fp.fileURL.spec);
view.database.AddDataSource(view.previousResults);
view.database.AddDataSource(view.memoryDataSource);
view.mPreviousResultDS = kRDFSvc.GetDataSource(fp.fileURL.spec);
view.database.AddDataSource(view.mPreviousResultDS);
}
document.getElementById('obs_orig_success')

Просмотреть файл

@ -66,6 +66,9 @@ const kIOSvc = Components.classes[kIOSvcContractID]
.getService(Components.interfaces.nsIIOService);
const nsIRDFService = Components.interfaces.nsIRDFService;
const nsIRDFDataSource = Components.interfaces.nsIRDFDataSource;
const nsIRDFRemoteDataSource = Components.interfaces.nsIRDFRemoteDataSource;
const nsIRDFPurgeableDataSource =
Components.interfaces.nsIRDFPurgeableDataSource;
const nsIRDFResource = Components.interfaces.nsIRDFResource;
const nsIRDFLiteral = Components.interfaces.nsIRDFLiteral;
const nsIRDFInt = Components.interfaces.nsIRDFInt;

Просмотреть файл

@ -48,7 +48,7 @@ var runQueue =
},
observe : function(aSubject, aTopic, aData)
{
item = this.mArray.shift();
var item = this.mArray.shift();
if (item) {
item.run(this);
}
@ -81,11 +81,10 @@ var itemCache =
}
return first;
}
var retItem = this.mArray[aResource.Value];
if (retItem) {
return retItem;
if (aResource.Value in this.mArray) {
return this.mArray[aResource.Value];
}
retItem = new runItem(aResource);
var retItem = new runItem(aResource);
this.mArray[aResource.Value] = retItem;
runQueue.push(retItem);
return retItem;
@ -167,8 +166,8 @@ runItem.prototype =
cat = cat.QueryInterface(nsIRDFLiteral);
name = name.QueryInterface(nsIRDFLiteral);
path = path.QueryInterface(nsIRDFLiteral);
xalan_fl = this.kXalan.resolve(cat.Value+"/"+path.Value);
xalan_ref = this.kXalan.resolve(cat.Value+"-gold/"+path.Value);
var xalan_fl = this.kXalan.resolve(cat.Value+"/"+path.Value);
var xalan_ref = this.kXalan.resolve(cat.Value+"-gold/"+path.Value);
dump(name.Value+" links to "+xalan_fl+"\n");
}
// Directory selected
@ -182,7 +181,6 @@ runItem.prototype =
m += 1;
child = children.getNext();
child.QueryInterface(nsIRDFResource);
//var aFoo = new runItem(child);
}
}
var refContent = this.loadTextFile(xalan_ref+".out");
@ -241,10 +239,6 @@ runItem.prototype =
isGood = false;
};
dump("This succeeded. "+isGood+"\n");
if (!isGood) {
DumpDOM(this.mResDoc);
DumpDOM(this.mRefDoc);
}
isGood = isGood.toString();
for (var i=0; i<this.kObservers.length; i++) {
var aObs = this.kObservers[i];

Просмотреть файл

@ -41,6 +41,7 @@ var view =
{
onRun : function()
{
runQueue.mArray = new Array();
var sels = this.boxObject.selection,a=new Object(),b=new Object(),k;
var rowResource, name, path;
for (k=0;k<sels.getRangeCount();k++){
@ -57,8 +58,6 @@ var view =
var current = this.boxObject.selection.currentIndex;
var rowResource = this.builder.getResourceAtIndex(current);
var item = itemCache.getItem(rowResource);
DumpDOM(item.mSourceDoc);
DumpDOM(item.mStyleDoc);
},
browseForRDF : function()
{
@ -73,7 +72,7 @@ var view =
},
dump_Good : function()
{
var enumi = this.database.GetSources(krTypeSucc, kGood, true);
var enumi = this.mResultDS.GetSources(krTypeSucc, kGood, true);
var k = 0;
while (enumi.hasMoreElements()) {
k += 1;
@ -83,29 +82,12 @@ var view =
},
prune_ds : function()
{
this.unassert(this.database.GetSources(krTypeSucc, kGood, true),
kGood);
this.unassert(this.database.GetSources(krTypeSucc, kBad, true),
kBad);
this.unassert(this.database.GetSources(krTypeSucc, kMixed, true),
kMixed);
runQueue.mArray = new Array();
if (this.mResultDS) {
this.mResultDS.QueryInterface(nsIRDFPurgeableDataSource).Sweep();
}
regressionStats.init()
itemCache.mArray = new Array();
},
unassert : function(aEnum, aResult)
{
var k = 0, item;
while (aEnum.hasMoreElements()) {
k += 1;
var item = aEnum.getNext();
try {
item = item.QueryInterface(nsIRDFResource);
this.database.Unassert(item, krTypeSucc, aResult, true);
} catch (e) {
dump("Can't unassert "+item+"\n");
}
}
},
setDataSource : function(aSpec)
{
var baseSpec;
@ -115,30 +97,33 @@ var view =
else {
baseSpec = document.getElementById("xalan_rdf").value;
}
dump(baseSpec+"\n");
var currentSources = this.database.GetDataSources();
while (currentSources.hasMoreElements()) {
var aSrc = currentSources.getNext().
QueryInterface(nsIRDFDataSource);
this.database.RemoveDataSource(aSrc);
if (this.mXalanDS && this.mXalanDS.URI == baseSpec) {
this.mXalanDS.QueryInterface(nsIRDFRemoteDataSource);
this.mXalanDS.Refresh(true);
}
var ds = kRDFSvc.GetDataSource(baseSpec);
if (!ds) {
else {
if (this.mXalanDS) {
this.database.RemoveDataSource(view.mXalanDS);
}
this.mXalanDS = kRDFSvc.GetDataSourceBlocking(baseSpec);
if (!this.mXalanDS) {
alert("Unable do load DataSource: "+baseSpec);
return;
}
view.memoryDataSource = doCreate(kRDFInMemContractID,
this.database.AddDataSource(this.mXalanDS);
}
regressionStats.init();
if (!this.mResultDS) {
this.mResultDS = doCreate(kRDFInMemContractID,
nsIRDFDataSource);
if (!view.memoryDataSource) {
alert("Unable to create write-protect InMemDatasource,"+
" not adding "+ baseSpec);
this.database.AddDataSource(view.mResultDS);
if (!this.mResultDS) {
alert("Unable to create result InMemDatasource");
return;
}
else {
view.database.AddObserver(new regressionStats());
view.database.AddDataSource(ds);
view.database.AddDataSource(view.memoryDataSource);
}
view.builder.rebuild();
this.builder.rebuild();
document.getElementById("xalan_rdf").value = baseSpec;
runItem.prototype.kXalan.init(runItem.prototype.kXalan.URLTYPE_STANDARD,
0, baseSpec, null, null);
@ -147,113 +132,86 @@ var view =
{
var index = view.boxObject.selection.currentIndex;
var res = view.builder.getResourceAtIndex(index);
var purp = view.database.GetTarget(res, krTypePurp, true);
var purp = view.mXalanDS.GetTarget(res, krTypePurp, true);
return (purp != null);
}
}
function state()
regressionStats =
{
observe: function(aSubject, aTopic, aData)
{
if (aTopic != 'success') {
return;
}
state.prototype =
var arc = (aData == "true") ? krTypeSuccCount : krTypeFailCount;
this.assertNewCount(aSubject, arc, 1);
},
init: function()
{
mSucceeded: 0,
mFailed: 0,
mMixed: 0
if (this.mRegressionDS) {
this.mRegressionDS.QueryInterface(nsIRDFPurgeableDataSource).Sweep();
}
function regressionStats()
{
else {
this.mRegressionDS =
doCreate(kRDFInMemContractID, nsIRDFDataSource);
view.database.AddDataSource(this.mRegressionDS);
}
regressionStats.prototype =
},
getParent: function(aDS, aSource)
{
QueryInterface: function(iid) {
if (!iid.equals(Components.interfaces.nsISupports) &&
!iid.equals(Components.interfaces.nsIRDFObserver))
throw Components.results.NS_ERROR_NO_INTERFACE;
return this;
// parent chached?
var parent = this.mRegressionDS.GetTarget(aSource, krTypeParent, true);
if (!parent) {
var labels = view.mXalanDS.ArcLabelsIn(aSource);
while (labels.hasMoreElements()) {
var arc = labels.getNext().QueryInterface(nsIRDFResource);
if (arc.Value.match(this.mChildRE)) {
parent = view.mXalanDS.GetSource(arc, aSource, true);
// cache the parent
this.mRegressionDS.Assert(aSource, krTypeParent,
parent, true);
}
}
}
return parent;
},
assertNewCount: function(aSource, aArc, aIncrement)
{
var root = kRDFSvc.GetResource('urn:root');
var count = 0;
var parent = view.database.GetTarget(aSource, krTypeParent, true);
while (parent) {
var countRes = view.database.GetTarget(parent, aArc, true);
// parent chached?
var parent = this.getParent(view.XalanDS, aSource);
while (parent && !parent.EqualsNode(root)) {
var countRes = this.mRegressionDS.GetTarget(parent, aArc, true);
if (countRes) {
count = countRes.QueryInterface(nsIRDFInt).Value;
}
var newCountRes = kRDFSvc.GetIntLiteral(count + aIncrement);
if (!newCountRes) {
return;
}
if (countRes) {
view.database.Change(parent, aArc, countRes, newCountRes);
this.mRegressionDS.Change(parent, aArc, countRes, newCountRes);
}
else {
view.database.Assert(parent, aArc, newCountRes, true);
this.mRegressionDS.Assert(parent, aArc, newCountRes, true);
}
parent = view.database.GetTarget(parent, krTypeParent, true);
parent = this.getParent(view.XalanDS, parent);
}
},
onAssert: function(aDataSource, aSource, aProperty, aTarget)
{
if (aProperty.EqualsNode(krTypeOrigSucc)) {
var arc = (aTarget.EqualsNode(kGood)) ? krTypeOrigSuccCount : krTypeOrigFailCount;
this.assertNewCount(aSource, arc, 1);
}
else if (aProperty.Value.substr(0, 44) == "http://www.w3.org/1999/02/22-rdf-syntax-ns#_") {
view.database.Assert(aTarget, krTypeParent, aSource, true);
}
},
onUnassert: function(aDataSource, aSource, aProperty, aTarget)
{
if (aProperty.EqualsNode(krTypeSucc)) {
var arc = (aTarget.EqualsNode(kGood)) ? krTypeSuccCount : krTypeFailCount;
this.assertNewCount(aSource, arc, -1);
}
},
onChange: function(aDataSource, aSource, aProperty, aOldTarget, aNewTarget)
{
},
onMove: function(aDataSource, aOldSource, aNewSource, aProperty, aTarget)
{
},
beginUpdateBatch: function(aDataSource)
{
},
endUpdateBatch: function(aDataSource)
{
}
mRegressionDS: 0,
mChildRE: /http:\/\/www\.w3\.org\/1999\/02\/22-rdf-syntax-ns#_/
}
function rdfObserve(aSubject, aTopic, aData)
{
if (aTopic == "success") {
var target = (aData == "true") ? kGood : kBad;
view.database.Assert(aSubject, krTypeSucc, target, true);
view.mResultDS.Assert(aSubject, krTypeSucc, target, true);
var parent = view.database.GetTarget(aSubject, krTypeParent, true);
while (parent) {
var count = 0;
var arc = (aData == "true") ? krTypeSuccCount : krTypeFailCount;
var countRes = view.database.GetTarget(parent, arc, true);
if (countRes) {
count = countRes.QueryInterface(nsIRDFInt).Value;
}
var newCountRes = kRDFSvc.GetIntLiteral(++count);
if (newCountRes) {
if (countRes) {
view.database.Change(parent, arc, countRes, newCountRes);
}
else {
view.database.Assert(parent, arc, newCountRes, true);
}
}
parent = view.database.GetTarget(parent, krTypeParent, true);
}
regressionStats.observe(aSubject, aTopic, aData);
}
}

Просмотреть файл

@ -63,6 +63,7 @@ function onNewResultView(event)
resultWin = window.openDialog('result-view.xul','_blank',
'chrome,resizable,dialog=no',
currentResultItem, currentRunItem);
return true;
}
var refInspector;