Skip to content

Commit

Permalink
add compute area for given bound, add different factories, add output…
Browse files Browse the repository at this point in the history
… for highcharts, add trellis chart emulation
  • Loading branch information
Clemens Hoffmann committed Jan 14, 2015
1 parent d0ed99a commit 8238906
Show file tree
Hide file tree
Showing 2 changed files with 155 additions and 10 deletions.
113 changes: 106 additions & 7 deletions benchmark/benchmark.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
$(function () {
$('#container').highcharts({
title: {
text: 'Fetch instances for different locations and bounds',
text: 'LEIPZIG_ZOOM_IN_AND_OUT',
x: -20 //center
},
subtitle: {
text: '',
x: -20
},
xAxis: {
categories: ['51.3333 12.3833 2500m', '2', '3', '4', '5', '6',
categories: ['1', '2', '3', '4', '5', '6',
'7', '8', '9', '10', '11', '12']
},
yAxis: {
Expand All @@ -42,23 +42,122 @@
},
series: [{
name: '1st Run',
data: [ 515, 538, 514, 348, 469, 800, 693, 1495, 508, 364, 1224, 492 ]
data: [ 1024, 677, 784, 519, 876, 1326, 375 ]
},
{
name: '2nd Run',
data: [ 501, 521, 495, 350, 507, 837, 717, 1532, 498, 345, 1317, 466 ]
data: [ 1086, 665, 769, 488, 910, 1298, 354 ]
},
{
name: '3rd Run',
data: [ 506, 498, 476, 359, 472, 813, 704, 1437, 454, 342, 1186, 481 ]
data: [ 1015, 674, 793, 537, 889, 1336, 400 ]
},
{
name: '4th Run',
data: [ 971, 698, 798, 496, 888, 1345, 356 ]
},
{
name: '5th Run',
data: [ 1014, 735, 798, 481, 905, 1440, 371 ]
}]
});

var charts = [],
$containers = $('#trellis td'),
datasets = [
{
name: 'Action 1 - Area: 200*200km',
data:[ 68, 68, 0 ]
},
{
name: 'Action 2 - Area: 100*100km',
data:[ 8, 8, 0 ]
},
{
name: 'Action 3 - Area: 50*50km',
data:[ 2, 2, 0 ]
},
{
name: 'Action 4 - Area: 20*20km',
data:[ 0, 0, 0 ]
},
{
name: 'Action 5 - Area: 200*200km',
data:[ 68, 68, 0 ]
},
{
name: 'Action 6 - Area: 2.000*2.000km',
data:[ 447, 441, 6 ]
},
{
name: 'Action 7 - Area: 20.000*20.000km',
data:[ 4, 0, 4 ]
}
];


$.each(datasets, function(i, dataset) {
charts.push(new Highcharts.Chart({

chart: {
renderTo: $containers[i],
type: 'bar',
marginLeft: i === 0 ? 100 : 10
},

title: {
text: dataset.name,
align: 'left',
x: i === 0 ? 90 : 0
},

credits: {
enabled: false
},

xAxis: {
categories: ['Fetched Items', 'Instances', 'Cluster'],
labels: {
enabled: i === 0
}
},

yAxis: {
allowDecimals: false,
title: {
text: null
},
min: 0
},


legend: {
enabled: false
},

series: [dataset]

}));
});

});
</script>
</head>
<body>
<div id="container">
<div id="container"></div>

<h1>Highcharts Trellis chart emulation</h2>

</div>
<table id="trellis">
<tr>
<td class="first"></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</body>
</html>
52 changes: 49 additions & 3 deletions benchmark/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,27 @@ var createSparqlService = function(url, graphUris) {
return result;
};

var distance = function(lat1, lon1, lat2, lon2) {
var r = 6371.0; // approx. radius of earth in km
var lat1Radians = (lat1 * Math.PI) / 180.0;
var lon1Radians = (lon1 * Math.PI) / 180.0;
var lat2Radians = (lat2 * Math.PI) / 180.0;
var lon2Radians = (lon2 * Math.PI) / 180.0;
var diffLonRadians = lon2Radians - lon1Radians;
var step = Math.cos(lat1Radians) * Math.cos(lat2Radians) * Math.cos(diffLonRadians) + (Math.sin(lat1Radians) * Math.sin(lat2Radians));
var d = r * Math.acos(step);
return d;
};

var area = function(lat1, lon1, lat2, lon2)
{
// lat1-lon1 is the upper-left corner, lat2-lon2 is the lower-right
var height = distance(lat1,lon1, lat2,lon1);
var width = distance(lat1,lon1, lat1,lon2);
return height * width;
};


// degrees to radians
var deg2rad = function(degrees) {
return Math.PI*degrees/180.0;
Expand Down Expand Up @@ -137,7 +158,18 @@ var LEIPZIG_TO_BERLIN = [
extend(BERLIN, { radius: 1000 }) // 100m
];

var actions = LEIPZIG_TO_BERLIN;
var LEIPZIG_ZOOM_IN_AND_OUT = [
extend(LEIPZIG, { radius: 100000 }), // 100km
extend(LEIPZIG, { radius: 50000 }), // 50km
extend(LEIPZIG, { radius: 25000 }), // 25km
extend(LEIPZIG, { radius: 10000 }), // 10km
extend(LEIPZIG, { radius: 100000 }), // 100km
extend(LEIPZIG, { radius: 1000000 }), // 1.000km
extend(LEIPZIG, { radius: 10000000 }) // 1.000km
];

//var actions = LEIPZIG_TO_BERLIN;
var actions = LEIPZIG_ZOOM_IN_AND_OUT;

var runAction = function(action) {
var bBox = boundingBox(action.lat, action.lon, action.radius);
Expand All @@ -151,16 +183,24 @@ var runAction = function(action) {
'itemCount' : 0,
'instanceCount' : 0,
'clusterCount' : 0,
'bounds': bounds
'bounds': bounds,
'highchartsOutput': []
};

var hrTime = process.hrtime();



var sparqlServiceA = createSparqlService('http://akswnc3.informatik.uni-leipzig.de/data/dbpedia/sparql', ['http://dbpedia.org']);
var sparqlServiceB = createSparqlService('http://linkedgeodata.org/sparql', ['http://linkedgeodata.org']);
var sparqlServiceC = createSparqlService('http://localhost/data/geolink/sparql', ['http://geolink.aksw.org/']);
var geoMapFactoryVirt = geo.GeoMapFactoryUtils.createWktMapFactory('http://www.w3.org/2003/01/geo/wgs84_pos#geometry', 'bif:st_intersects', 'bif:st_geomFromText');
var geoMapFactoryAsWktVirt = geo.GeoMapFactoryUtils.createWktMapFactory('http://www.opengis.net/ont/geosparql#asWKT', 'bif:st_intersects', 'bif:st_geomFromText');
var geoMapFactoryWgs = geo.GeoMapFactoryUtils.wgs84MapFactory;
var conceptA = sparql.ConceptUtils.createTypeConcept('http://dbpedia.org/ontology/Place');
var conceptB = sparql.ConceptUtils.createSubjectConcept();

var dataSource = createMapDataSource(sparqlServiceA, geoMapFactoryVirt, conceptA, '#CC0020');
var dataSource = createMapDataSource(sparqlServiceB, geoMapFactoryAsWktVirt, conceptB, '#CC0020');

var result = dataSource.fetchData(bounds).then(function(items) {

Expand All @@ -183,6 +223,9 @@ var runAction = function(action) {
stat.itemCount = items.length;
stat.clusterCount = clusterCount;
stat.instanceCount = instanceCount;
stat.highchartsOutput.push(items.length);
stat.highchartsOutput.push(instanceCount);
stat.highchartsOutput.push(clusterCount);

return stat;

Expand Down Expand Up @@ -231,13 +274,16 @@ var runActions = function(nextActionFn, stats) {
return result;
};


console.log('Benchmark is running...');
/** RUN BENCHMARK */
runBenchmark(actions, runAction).then(function(stats) {
// done
console.log('Result\n', stats);
});



/*
// compute bounds in a 1000km radius of Leipzig
var boundsLeipzig = boundingBox(LEIPZIG.lat, LEIPZIG.lon, 1000000);
Expand Down

0 comments on commit 8238906

Please sign in to comment.