Skip to content

Instantly share code, notes, and snippets.

@airbreather
Created April 28, 2017 03:20
Show Gist options
  • Save airbreather/3730e27e86171727d851ef2264ffc318 to your computer and use it in GitHub Desktop.
Save airbreather/3730e27e86171727d851ef2264ffc318 to your computer and use it in GitHub Desktop.
/*
* Licensed to SharpSoftware under one or more contributor
* license agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* SharpSoftware licenses this file to you under the Apache License,
* Version 2.0 (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.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using NetTopologySuite.Features;
using Itinero.Test.Functional.Staging;
using System;
using System.IO;
using Itinero.Logging;
using Itinero.Test.Functional.Tests;
using Itinero.IO.Osm;
using Itinero.LocalGeo;
using OsmSharp.Streams;
using Itinero.Osm.Vehicles;
using System.Runtime;
namespace Itinero.Test.Functional
{
public class Program
{
private static Logger _logger;
public static void Main(string[] args)
{
////Constants.MemoryArrayFactory = new UnmanagedMemoryArrayFactory();
// enable logging.
OsmSharp.Logging.Logger.LogAction = (o, level, message, parameters) =>
{
if (o == "Test" && message[0] == '§')
{
Console.WriteLine("[{0}] {1} - {2}", o, level, message.Substring(1));
}
};
Itinero.Logging.Logger.LogAction = (o, level, message, parameters) =>
{
if (o == "Test" && message[0] == '§')
{
Console.WriteLine("[{0}] {1} - {2}", o, level, message.Substring(1));
}
};
_logger = new Logger("Default");
Itinero.Osm.Vehicles.Vehicle.RegisterVehicles();
#if DEBUG
_logger.Log(TraceEventType.Information, "Performance tests are running in Debug, please run in Release mode.");
#endif
for (int i = 0; i < 5; ++i)
{
// test building a routerdb.
var routerdb = new RouterDb();
var info = new PerformanceInfoConsumer("§Loading OSM data");
info.Start();
////using (var stream = File.OpenRead(Download.LuxembourgLocal))
using (var stream = File.OpenRead(@"E:\planet-bits2.osm.pbf"))
{
var source = new PBFOsmStreamSource(stream);
var progress = new OsmSharp.Streams.Filters.OsmStreamFilterProgress();
progress.RegisterSource(source);
routerdb.LoadOsmData(progress, false, true, Vehicle.Car);
info.Stop();
}
info = new PerformanceInfoConsumer("§Adding contracted db");
info.Start();
routerdb.AddContracted(Vehicle.Car.Fastest(), true);
info.Stop();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment