From 4bd5319d5fb57422939410cbbc4a4b8d195b2ebf Mon Sep 17 00:00:00 2001 From: XD Date: Fri, 22 Mar 2024 14:56:06 +0100 Subject: [PATCH] fix: reformat code --- perf/perftest-inband-percent.js | 314 ++++++++++++++++---------------- perf/perftest-inband.js | 24 +-- 2 files changed, 172 insertions(+), 166 deletions(-) diff --git a/perf/perftest-inband-percent.js b/perf/perftest-inband-percent.js index 7b59a49..8bfebae 100644 --- a/perf/perftest-inband-percent.js +++ b/perf/perftest-inband-percent.js @@ -1,6 +1,6 @@ const Benchmark = require("benchmark"); const Store = require("n3").Store; -const {RdfStore} = require('rdf-stores'); +const { RdfStore } = require("rdf-stores"); const rdfDereference = require("rdf-dereference").default; const NamedNode = require("n3").NamedNode; @@ -12,19 +12,19 @@ Benchmark.options.minSamples = 100; Benchmark.options.maxTime = 2; let main = async function () { - let suite = new Benchmark.Suite(undefined, {maxTime: 2}); + let suite = new Benchmark.Suite(undefined, { maxTime: 2 }); let kboData = RdfStore.createDefault(); let kboData130Quads = RdfStore.createDefault(); let kboData1300Quads = RdfStore.createDefault(); let shaclKBO = RdfStore.createDefault(); //Load the quads from the file let kboDataStream = ( - await rdfDereference.dereference("./perf/resources/kbo.ttl", { - localFiles: true, - }) + await rdfDereference.dereference("./perf/resources/kbo.ttl", { + localFiles: true, + }) ).data; - //load the shacl shape from the file + //load the shacl shape from the file let kboDataStream130Quads = ( await rdfDereference.dereference("./perf/resources/kbo-130-quads.ttl", { localFiles: true, @@ -33,9 +33,9 @@ let main = async function () { //load the shacl shape from the file let kboDataStream1300Quads = ( - await rdfDereference.dereference("./perf/resources/kbo-1300-quads.ttl", { - localFiles: true, - }) + await rdfDereference.dereference("./perf/resources/kbo-1300-quads.ttl", { + localFiles: true, + }) ).data; //load the shacl shape from the file @@ -52,17 +52,23 @@ let main = async function () { }); await new Promise((resolve, reject) => { - kboData130Quads.import(kboDataStream130Quads).on("end", resolve).on("error", reject); + kboData130Quads + .import(kboDataStream130Quads) + .on("end", resolve) + .on("error", reject); }); await new Promise((resolve, reject) => { - kboData1300Quads.import(kboDataStream1300Quads).on("end", resolve).on("error", reject); + kboData1300Quads + .import(kboDataStream1300Quads) + .on("end", resolve) + .on("error", reject); }); await new Promise((resolve, reject) => { shaclKBO.import(kboShaclStream).on("end", resolve).on("error", reject); }); - ////console.error(kboData130Quads.size); + ////console.log(kboData130Quads.size); let extractor = new CBDShapeExtractor(); let extractorWithShape = new CBDShapeExtractor(shaclKBO); @@ -81,92 +87,87 @@ let main = async function () { //In-band tests - 13 quads //Extraction only star-shapes (CBD) + blank nodes to be extracted suite - //Extraction only star-shapes (CBD) + blank nodes to be extracted - .add("Extract1#CBDAndBlankNode", async function () { + //Extraction only star-shapes (CBD) + blank nodes to be extracted + .add("Extract1#CBDAndBlankNode", async function () { let result = await extractor.extract( kboData, new NamedNode("https://kbopub.economie.fgov.be/kbo#0877248501.2022.11") ); - //console.error("Extract1#CBDAndBlankNode returned:" + result.length + " quads."); + //console.log("Extract1#CBDAndBlankNode returned:" + result.length + " quads."); + }) + //Extraction only star-shapes (CBD) + blank nodes to be extracted, retrieve 13 quads out of 130 + .add("Extract1.1#CBDAndBlankNodeTenPercent", async function () { + let result = await extractor.extract( + kboData130Quads, + new NamedNode("https://kbopub.economie.fgov.be/kbo#0877248501.2022.11") + ); + //console.log("Extract1.1#CBDAndBlankNodeTenPercent returned: " + result.length + " quads."); }) - //Extraction only star-shapes (CBD) + blank nodes to be extracted, retrieve 13 quads out of 130 - .add("Extract1.1#CBDAndBlankNodeTenPercent", async function () { - let result = await extractor.extract( - kboData130Quads, - new NamedNode("https://kbopub.economie.fgov.be/kbo#0877248501.2022.11") - ); - //console.error("Extract1.1#CBDAndBlankNodeTenPercent returned: " + result.length + " quads."); - }) - - //Extraction only star-shapes (CBD) + blank nodes to be extracted, retrieve 13 quads out of 1300 - .add("Extract1.2#CBDAndBlankNodeOnePercent", async function () { - let result = await extractor.extract( - kboData1300Quads, - new NamedNode("https://kbopub.economie.fgov.be/kbo#0877248501.2022.11") - ); - //console.error("Extract1.2#CBDAndBlankNodeOnePercent returned: " + result.length + " quads."); - }) - - - - //Extraction CBD + named graphs - .add("Extract2#CBDAndNamedGraphs", async function () { - let result = await extractor.extract( - kboData, - new NamedNode("https://kbopub.economie.fgov.be/kbo#0417199869.2022.11") - ); - //console.error("Extract2#CBDAndNamedGraphs returned: " + result.length + " quads."); - }) - - //Extraction CBD + named graphs,retrieve 13 quads out of 130 - .add("Extract2.1#CBDAndNamedGraphsTenPercent", async function () { - let result = await extractor.extract( - kboData130Quads, - new NamedNode("https://kbopub.economie.fgov.be/kbo#0417199869.2022.11") - ); - //console.error("Extract2.1#CBDAndNamedGraphsTenPercent returned: " + result.length + " quads."); - }) - //Extraction CBD + named graphs,retrieve 13 quads out of 1300 - .add("Extract2.2#CBDAndNamedGraphsOnePercent", async function () { - let result = await extractor.extract( - kboData1300Quads, - new NamedNode("https://kbopub.economie.fgov.be/kbo#0417199869.2022.11") - ); - //console.error("Extract2.2#CBDAndNamedGraphsOnePercent returned: " + result.length + " quads."); - }) + //Extraction only star-shapes (CBD) + blank nodes to be extracted, retrieve 13 quads out of 1300 + .add("Extract1.2#CBDAndBlankNodeOnePercent", async function () { + let result = await extractor.extract( + kboData1300Quads, + new NamedNode("https://kbopub.economie.fgov.be/kbo#0877248501.2022.11") + ); + //console.log("Extract1.2#CBDAndBlankNodeOnePercent returned: " + result.length + " quads."); + }) + //Extraction CBD + named graphs + .add("Extract2#CBDAndNamedGraphs", async function () { + let result = await extractor.extract( + kboData, + new NamedNode("https://kbopub.economie.fgov.be/kbo#0417199869.2022.11") + ); + //console.log("Extract2#CBDAndNamedGraphs returned: " + result.length + " quads."); + }) - //Extraction CBD + Simple Shape not adding any triples other than what CBD gives - .add("Extract3#CBDAndSimpleShape", async function () { - let result = await extractorWithShape.extract( - kboData, - new NamedNode("https://kbopub.economie.fgov.be/kbo#0877248501.2022.11"), - new NamedNode("https://kbopub.economie.fgov.be/kbo#LegalEntityShape") - ); - //console.error("Extract3#CBDAndSimpleShape returned: " + result.length + " quads."); - }) - //Extraction CBD + Simple Shape not adding any triples other than what CBD gives, retrieve 13 quads out of 130 - .add("Extract3.1#CBDAndSimpleShapeTenPercent", async function () { - let result = await extractorWithShape.extract( - kboData130Quads, - new NamedNode("https://kbopub.economie.fgov.be/kbo#0877248501.2022.11"), - new NamedNode("https://kbopub.economie.fgov.be/kbo#LegalEntityShape") - ); - //console.error("Extract3.1#CBDAndSimpleShapeTenPercent returned: " + result.length + " quads."); - }) + //Extraction CBD + named graphs,retrieve 13 quads out of 130 + .add("Extract2.1#CBDAndNamedGraphsTenPercent", async function () { + let result = await extractor.extract( + kboData130Quads, + new NamedNode("https://kbopub.economie.fgov.be/kbo#0417199869.2022.11") + ); + //console.log("Extract2.1#CBDAndNamedGraphsTenPercent returned: " + result.length + " quads."); + }) - //Extraction CBD + Simple Shape not adding any triples other than what CBD gives, retrieve 13 quads out of 1300 - .add("Extract3.2#CBDAndSimpleShapeOnePercent", async function () { - let result = await extractorWithShape.extract( - kboData1300Quads, - new NamedNode("https://kbopub.economie.fgov.be/kbo#0877248501.2022.11"), - new NamedNode("https://kbopub.economie.fgov.be/kbo#LegalEntityShape") - ); - //console.error("Extract3.2#CBDAndSimpleShapeOnePercent returned: " + result.length + " quads."); - }) + //Extraction CBD + named graphs,retrieve 13 quads out of 1300 + .add("Extract2.2#CBDAndNamedGraphsOnePercent", async function () { + let result = await extractor.extract( + kboData1300Quads, + new NamedNode("https://kbopub.economie.fgov.be/kbo#0417199869.2022.11") + ); + //console.log("Extract2.2#CBDAndNamedGraphsOnePercent returned: " + result.length + " quads."); + }) + //Extraction CBD + Simple Shape not adding any triples other than what CBD gives + .add("Extract3#CBDAndSimpleShape", async function () { + let result = await extractorWithShape.extract( + kboData, + new NamedNode("https://kbopub.economie.fgov.be/kbo#0877248501.2022.11"), + new NamedNode("https://kbopub.economie.fgov.be/kbo#LegalEntityShape") + ); + //console.log("Extract3#CBDAndSimpleShape returned: " + result.length + " quads."); + }) + //Extraction CBD + Simple Shape not adding any triples other than what CBD gives, retrieve 13 quads out of 130 + .add("Extract3.1#CBDAndSimpleShapeTenPercent", async function () { + let result = await extractorWithShape.extract( + kboData130Quads, + new NamedNode("https://kbopub.economie.fgov.be/kbo#0877248501.2022.11"), + new NamedNode("https://kbopub.economie.fgov.be/kbo#LegalEntityShape") + ); + //console.log("Extract3.1#CBDAndSimpleShapeTenPercent returned: " + result.length + " quads."); + }) + //Extraction CBD + Simple Shape not adding any triples other than what CBD gives, retrieve 13 quads out of 1300 + .add("Extract3.2#CBDAndSimpleShapeOnePercent", async function () { + let result = await extractorWithShape.extract( + kboData1300Quads, + new NamedNode("https://kbopub.economie.fgov.be/kbo#0877248501.2022.11"), + new NamedNode("https://kbopub.economie.fgov.be/kbo#LegalEntityShape") + ); + //console.log("Extract3.2#CBDAndSimpleShapeOnePercent returned: " + result.length + " quads."); + }) // Extraction CBD + named graphs + Simple shape that does not add any triples other than already present .add("Extract4#CBDAndSimpleShapeAndNamedGraphs", async function () { @@ -175,31 +176,38 @@ let main = async function () { new NamedNode("https://kbopub.economie.fgov.be/kbo#0417199869.2022.11"), new NamedNode("https://kbopub.economie.fgov.be/kbo#LegalEntityShape") ); - //console.error("Extract4#CBDAndSimpleShapeAndNamedGraphs returned: " + result.length + " quads."); + //console.log("Extract4#CBDAndSimpleShapeAndNamedGraphs returned: " + result.length + " quads."); }) - // Extraction CBD + named graphs + Simple shape that does not add any triples other than already present, retrieve 13 quads out of 130 - .add("Extract4.1#CBDAndSimpleShapeAndNamedGraphsTenPercent", async function () { + // Extraction CBD + named graphs + Simple shape that does not add any triples other than already present, retrieve 13 quads out of 130 + .add( + "Extract4.1#CBDAndSimpleShapeAndNamedGraphsTenPercent", + async function () { let result = await extractorWithShape.extract( - kboData130Quads, - new NamedNode("https://kbopub.economie.fgov.be/kbo#0417199869.2022.11"), - new NamedNode("https://kbopub.economie.fgov.be/kbo#LegalEntityShape") + kboData130Quads, + new NamedNode( + "https://kbopub.economie.fgov.be/kbo#0417199869.2022.11" + ), + new NamedNode("https://kbopub.economie.fgov.be/kbo#LegalEntityShape") ); - //console.error("Extract4.1#CBDAndSimpleShapeAndNamedGraphsTenPercent returned: " + result.length + " quads."); - }) - // Extraction CBD + named graphs + Simple shape that does not add any triples other than already present, retrieve 13 quads out of 1300 - .add("Extract4.2#CBDAndSimpleShapeAndNamedGraphsOnePercent", async function () { + //console.log("Extract4.1#CBDAndSimpleShapeAndNamedGraphsTenPercent returned: " + result.length + " quads."); + } + ) + // Extraction CBD + named graphs + Simple shape that does not add any triples other than already present, retrieve 13 quads out of 1300 + .add( + "Extract4.2#CBDAndSimpleShapeAndNamedGraphsOnePercent", + async function () { let result = await extractorWithShape.extract( - kboData1300Quads, - new NamedNode("https://kbopub.economie.fgov.be/kbo#0417199869.2022.11"), - new NamedNode("https://kbopub.economie.fgov.be/kbo#LegalEntityShape") + kboData1300Quads, + new NamedNode( + "https://kbopub.economie.fgov.be/kbo#0417199869.2022.11" + ), + new NamedNode("https://kbopub.economie.fgov.be/kbo#LegalEntityShape") ); - //console.error("Extract4.2#CBDAndSimpleShapeAndNamedGraphsOnePercent returned: " + result.length + " quads."); - }) - - - + //console.log("Extract4.2#CBDAndSimpleShapeAndNamedGraphsOnePercent returned: " + result.length + " quads."); + } + ) - // Extraction Shape selecting specific property paths, but not too complex + // Extraction Shape selecting specific property paths, but not too complex .add("Extract5#CBDAndShaclExtended", async function () { let result = await extractorWithShape.extract( kboData, @@ -208,34 +216,32 @@ let main = async function () { "https://kbopub.economie.fgov.be/kbo#LegalEntityShapeExtended" ) ); - //console.error("Extract5#CBDAndShaclExtended returned: " + result.length + " quads."); + //console.log("Extract5#CBDAndShaclExtended returned: " + result.length + " quads."); }) - // Extraction Shape selecting specific property paths, but not too complex,retrieve 13 quads out of 130 - .add("Extract5.1#CBDAndShaclExtendedTenPercent", async function () { - let result = await extractorWithShape.extract( - kboData130Quads, - new NamedNode("https://kbopub.economie.fgov.be/kbo#0877248501.2023.11"), - new NamedNode( - "https://kbopub.economie.fgov.be/kbo#LegalEntityShapeExtended" - ) - ); - //console.error("Extract5.1#CBDAndShaclExtendedTenPercent returned: " + result.length + " quads."); - }) - - // Extraction Shape selecting specific property paths, but not too complex,retrieve 13 quads out of 1300 - .add("Extract5.2#CBDAndShaclExtendedOnePercent", async function () { - let result = await extractorWithShape.extract( - kboData1300Quads, - new NamedNode("https://kbopub.economie.fgov.be/kbo#0877248501.2023.11"), - new NamedNode( - "https://kbopub.economie.fgov.be/kbo#LegalEntityShapeExtended" - ) - ); - //console.error("Extract5.2#CBDAndShaclExtendedOnePercent returned: " + result.length + " quads."); - }) + // Extraction Shape selecting specific property paths, but not too complex,retrieve 13 quads out of 130 + .add("Extract5.1#CBDAndShaclExtendedTenPercent", async function () { + let result = await extractorWithShape.extract( + kboData130Quads, + new NamedNode("https://kbopub.economie.fgov.be/kbo#0877248501.2023.11"), + new NamedNode( + "https://kbopub.economie.fgov.be/kbo#LegalEntityShapeExtended" + ) + ); + //console.log("Extract5.1#CBDAndShaclExtendedTenPercent returned: " + result.length + " quads."); + }) - + // Extraction Shape selecting specific property paths, but not too complex,retrieve 13 quads out of 1300 + .add("Extract5.2#CBDAndShaclExtendedOnePercent", async function () { + let result = await extractorWithShape.extract( + kboData1300Quads, + new NamedNode("https://kbopub.economie.fgov.be/kbo#0877248501.2023.11"), + new NamedNode( + "https://kbopub.economie.fgov.be/kbo#LegalEntityShapeExtended" + ) + ); + //console.log("Extract5.2#CBDAndShaclExtendedOnePercent returned: " + result.length + " quads."); + }) //Extraction Complex shape with conditionals .add("Extract6#CBDAndShaclExtendedComplex", async function () { @@ -246,30 +252,30 @@ let main = async function () { "https://kbopub.economie.fgov.be/kbo#LegalEntityShapeConditions" ) ); - //console.error("Extract6#CBDAndShaclExtendedComplex returned: " + result.length + " quads."); + //console.log("Extract6#CBDAndShaclExtendedComplex returned: " + result.length + " quads."); + }) + //Extraction Complex shape with conditionals,retrieve 13 quads out of 130 + .add("Extract6.1#CBDAndShaclExtendedComplexTenPercent", async function () { + let result = await extractorWithShape.extract( + kboData130Quads, + new NamedNode("https://kbopub.economie.fgov.be/kbo#0877248501.2023.11"), + new NamedNode( + "https://kbopub.economie.fgov.be/kbo#LegalEntityShapeConditions" + ) + ); + //console.log("Extract6.1#CBDAndShaclExtendedComplexTenPercent returned: " + result.length + " quads."); + }) + //Extraction Complex shape with conditionals,retrieve 13 quads out of 130 + .add("Extract6.2#CBDAndShaclExtendedComplexOnePercent", async function () { + let result = await extractorWithShape.extract( + kboData1300Quads, + new NamedNode("https://kbopub.economie.fgov.be/kbo#0877248501.2023.11"), + new NamedNode( + "https://kbopub.economie.fgov.be/kbo#LegalEntityShapeConditions" + ) + ); + //console.log("Extract6.2#CBDAndShaclExtendedComplexOnePercent returned: " + result.length + " quads."); }) - //Extraction Complex shape with conditionals,retrieve 13 quads out of 130 - .add("Extract6.1#CBDAndShaclExtendedComplexTenPercent", async function () { - let result = await extractorWithShape.extract( - kboData130Quads, - new NamedNode("https://kbopub.economie.fgov.be/kbo#0877248501.2023.11"), - new NamedNode( - "https://kbopub.economie.fgov.be/kbo#LegalEntityShapeConditions" - ) - ); - //console.error("Extract6.1#CBDAndShaclExtendedComplexTenPercent returned: " + result.length + " quads."); - }) - //Extraction Complex shape with conditionals,retrieve 13 quads out of 130 - .add("Extract6.2#CBDAndShaclExtendedComplexOnePercent", async function () { - let result = await extractorWithShape.extract( - kboData1300Quads, - new NamedNode("https://kbopub.economie.fgov.be/kbo#0877248501.2023.11"), - new NamedNode( - "https://kbopub.economie.fgov.be/kbo#LegalEntityShapeConditions" - ) - ); - //console.error("Extract6.2#CBDAndShaclExtendedComplexOnePercent returned: " + result.length + " quads."); - }) // add listeners .on("complete", function () { diff --git a/perf/perftest-inband.js b/perf/perftest-inband.js index be844ca..bcea7dd 100644 --- a/perf/perftest-inband.js +++ b/perf/perftest-inband.js @@ -1,5 +1,5 @@ const Benchmark = require("benchmark"); -const {RdfStore} = require('rdf-stores'); +const { RdfStore } = require("rdf-stores"); const rdfDereference = require("rdf-dereference").default; const NamedNode = require("n3").NamedNode; @@ -26,7 +26,7 @@ let main = async function () { await rdfDereference.dereference( "./perf/resources/shacl-kbo.ttl", // "./tests/06 - shapes and named graphs/shape.ttl", - { localFiles: true }, + { localFiles: true } ) ).data; @@ -60,9 +60,9 @@ let main = async function () { .add("CBDAndBlankNode", async function () { let result = await extractor.extract( kboData, - new NamedNode("https://kbopub.economie.fgov.be/kbo#0877248501.2022.11"), + new NamedNode("https://kbopub.economie.fgov.be/kbo#0877248501.2022.11") ); - // console.error("Extract#CBD returned " + result.length + " quads."); + // console.log("Extract1#CBD returned " + result.length + " quads."); }) //Extraction CBD + named graphs .add("CBDAndNamedGraphs", async function () { @@ -70,7 +70,9 @@ let main = async function () { kboData, new NamedNode("https://kbopub.economie.fgov.be/kbo#0417199869.2022.11") ); - // console.error("Extract2#CBDAndNamedGraphs returned " + result.length + " quads."); + console.log( + "Extract2#CBDAndNamedGraphs returned " + result.length + " quads." + ); }) //Extraction CBD + Simple Shape not adding any triples other than what CBD gives @@ -80,7 +82,7 @@ let main = async function () { new NamedNode("https://kbopub.economie.fgov.be/kbo#0877248501.2022.11"), new NamedNode("https://kbopub.economie.fgov.be/kbo#LegalEntityShape") ); - // console.error("Extract3#CBDAndSimpleShape " + result.length + " quads."); + // console.log("Extract3#CBDAndSimpleShape " + result.length + " quads."); }) // Extraction CBD + named graphs + Simple shape that does not add any triples other than already present @@ -90,10 +92,9 @@ let main = async function () { new NamedNode("https://kbopub.economie.fgov.be/kbo#0417199869.2022.11"), new NamedNode("https://kbopub.economie.fgov.be/kbo#LegalEntityShape") ); - // console.error("Extract4#CBDAndSimpleShapeAndNamedGraphs " + result.length + " quads."); + // console.log("Extract4#CBDAndSimpleShapeAndNamedGraphs " + result.length + " quads."); }) - // Extraction Shape selecting specific property paths, but not too complex .add("CBDAndShaclExtended", async function () { let result = await extractorWithShape.extract( @@ -103,7 +104,7 @@ let main = async function () { "https://kbopub.economie.fgov.be/kbo#LegalEntityShapeExtended" ) ); - // console.error("Extract5#CBDAndShaclExtended " + result.length + " quads."); + // console.log("Extract5#CBDAndShaclExtended " + result.length + " quads."); }) // Extraction Complex shape with conditionals @@ -115,10 +116,10 @@ let main = async function () { "https://kbopub.economie.fgov.be/kbo#LegalEntityShapeConditions" ) ); - // console.error("Extract6#CBDAndShaclExtendedComplex " + result.length + " quads."); + // console.log("Extract6#CBDAndShaclExtendedComplex " + result.length + " quads."); }) //add listeners - .on('cycle', function(event) { + .on("cycle", function (event) { console.log(String(event.target)); }) // add listeners @@ -134,7 +135,6 @@ let main = async function () { }); renderResults("inband", results); - }) // run async .run({ async: true });