Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "test/mvt-fixtures"]
path = test/mvt-fixtures
url = https://github.com/mapbox/mvt-fixtures.git
[submodule "bench/mvt-bench-fixtures"]
path = bench/mvt-bench-fixtures
url = https://github.com/mapbox/mvt-bench-fixtures.git
10 changes: 10 additions & 0 deletions VectorTileCs.sln
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Util", "src\Util\Util.cspro
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VectorTiles.Tests", "src\VectorTiles.Tests\VectorTiles.Tests.csproj", "{067456C0-086C-46A8-B37F-1405717B7BFC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bench", "src\Bench\Bench.csproj", "{5FA56C72-348A-4B52-980C-EA8287E66422}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -71,6 +73,14 @@ Global
{067456C0-086C-46A8-B37F-1405717B7BFC}.Release|Any CPU.Build.0 = Release|Any CPU
{067456C0-086C-46A8-B37F-1405717B7BFC}.Release|x64.ActiveCfg = Release|Any CPU
{067456C0-086C-46A8-B37F-1405717B7BFC}.Release|x64.Build.0 = Release|Any CPU
{5FA56C72-348A-4B52-980C-EA8287E66422}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5FA56C72-348A-4B52-980C-EA8287E66422}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5FA56C72-348A-4B52-980C-EA8287E66422}.Debug|x64.ActiveCfg = Debug|Any CPU
{5FA56C72-348A-4B52-980C-EA8287E66422}.Debug|x64.Build.0 = Debug|Any CPU
{5FA56C72-348A-4B52-980C-EA8287E66422}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5FA56C72-348A-4B52-980C-EA8287E66422}.Release|Any CPU.Build.0 = Release|Any CPU
{5FA56C72-348A-4B52-980C-EA8287E66422}.Release|x64.ActiveCfg = Release|Any CPU
{5FA56C72-348A-4B52-980C-EA8287E66422}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@ after_test:
Add-AppveyorTest "Violation of Rule $($codeAnalysisError.CheckId): $($codeAnalysisError.TypeName) Line Number: $($issueNode.Line)" -Outcome Failed -FileName "$($issueNode.Path)\$($codeAnalysisError.Issue.File)" -ErrorMessage $($issueNode.InnerXml);
}
Push-AppveyorArtifact fxcop.out.xml;
- cmd: cd bin && bench
1 change: 1 addition & 0 deletions bench/mvt-bench-fixtures
Submodule mvt-bench-fixtures added at 77758e
66 changes: 66 additions & 0 deletions src/Bench/Bench.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{5FA56C72-348A-4B52-980C-EA8287E66422}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Bench</RootNamespace>
<AssemblyName>Bench</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\VectorTileReader\VectorTileReader.csproj">
<Project>{4656b308-1492-4a22-a73e-06bf6aa858f2}</Project>
<Name>VectorTileReader</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
140 changes: 140 additions & 0 deletions src/Bench/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
using Mapbox.VectorTile;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;

namespace ProfileDecoding
{
class Program
{
static int Main(string[] args)
{

//ul 14/4680/6260
//lr 14/4693/6274
ulong zoom = 14;
ulong minCol = 4680;
ulong minRow = 6260;
ulong maxCol = 4693;
ulong maxRow = 6274;

string fixturePath = Path.Combine("..", "bench", "mvt-bench-fixtures", "fixtures");
if (!Directory.Exists(fixturePath))
{
Console.Error.WriteLine("fixture directory not found: [{0}]", fixturePath);
return 1;
}

ulong nrOfTiles = (maxCol - minCol + 1) * (maxRow - minRow + 1);
List<TileData> tiles = new List<TileData>((int)nrOfTiles);

//https://a.tiles.mapbox.com/v4/mapbox.mapbox-terrain-v2,mapbox.mapbox-streets-v7/13/2343/3133.vector.pbf?access_token=
using (GZipWebClient wc = new GZipWebClient())
{
for (ulong col = minCol; col <= maxCol; col++)
{
for (ulong row = minRow; row <= maxRow; row++)
{
string fileName = string.Format("{0}-{1}-{2}.mvt", zoom, col, row);
fileName = Path.Combine(fixturePath, fileName);
if (!File.Exists(fileName))
{
Console.Error.WriteLine("fixture mvt not found: [{0}]", fileName);
return 1;
} else
{
tiles.Add(new TileData() {
zoom = zoom,
col = col,
row = row,
pbf = File.ReadAllBytes(fileName)
});
}
}
}
}

Stopwatch stopWatch = new Stopwatch();
List<long> elapsed = new List<long>();

for (int i = 0; i <= 100; i++)
{
Console.Write(".");
stopWatch.Start();
foreach (var tile in tiles)
{
VectorTileReader.Decode(tile.zoom, tile.col, tile.row, tile.pbf);
}
stopWatch.Stop();
//skip first run
if (i != 0)
{
elapsed.Add(stopWatch.ElapsedMilliseconds);
}
stopWatch.Reset();
}


Console.WriteLine(
"{0}{0}runs:{1}{0}tiles per run:{2}{0}min [ms]:{3}{0}max [ms]:{4}{0}avg [ms]:{5}{0}StdDev:{6:0.00}{0}overall [ms]:{7}",
Environment.NewLine,
elapsed.Count,
tiles.Count,
elapsed.Min(),
elapsed.Max(),
elapsed.Average(),
StdDev(elapsed),
elapsed.Sum()
);


return 0;
}


private static double StdDev(List<long> values)
{
double ret = 0;
int count = values.Count();
if (count > 1)
{
//Compute the Average
double avg = values.Average();

//Perform the Sum of (value-avg)^2
double sum = values.Sum(d => (d - avg) * (d - avg));

//Put it all together
ret = Math.Sqrt(sum / count);
}
return ret;
}


}


public struct TileData
{
public ulong zoom;
public ulong col;
public ulong row;
public byte[] pbf;
}


public class GZipWebClient : WebClient
{
protected override WebRequest GetWebRequest(Uri address)
{
HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(address);
request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
return request;
}
}

}
36 changes: 36 additions & 0 deletions src/Bench/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ProfileDecoding")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ProfileDecoding")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("5fa56c72-348a-4b52-980c-ea8287e66422")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
3 changes: 3 additions & 0 deletions src/Bench/app.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/></startup></configuration>
2 changes: 1 addition & 1 deletion src/DemoConsoleApp/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
<configuration>
<startup>

<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/></startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/></startup>
</configuration>
2 changes: 1 addition & 1 deletion src/DemoConsoleApp/DemoConsoleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DemoConsoleApp</RootNamespace>
<AssemblyName>DemoConsoleApp</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<PublishUrl>publish\</PublishUrl>
Expand Down
14 changes: 7 additions & 7 deletions src/Geometry/DecodeGeometry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ ulong extent
, ulong tileColumn
, ulong tileRow
, GeomType geomType
, List<UInt32> geometry
, List<uint> geometry
)
{

Expand Down Expand Up @@ -67,7 +67,8 @@ ulong extent
geomOut.Add(geomTmp);
geomTmp = new List<Point2d>();
}
geomTmp.Add(new Point2d() { X = cursorX, Y = cursorY });
Point2d pntTmp = new Point2d(cursorX, cursorY);
geomTmp.Add(pntTmp);
}
}
if (cmd == Commands.ClosePath)
Expand All @@ -91,11 +92,10 @@ ulong extent
private static Point2d zigzagDecode(long x, long y)
{

return new Point2d()
{
X = ((x >> 1) ^ (-(x & 1))),
Y = ((y >> 1) ^ (-(y & 1)))
};
return new Point2d(
((x >> 1) ^ (-(x & 1))),
((y >> 1) ^ (-(y & 1)))
);
}
}
}
10 changes: 8 additions & 2 deletions src/Geometry/Geometry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public enum GeomType
POLYGON = 3
}

public class LatLng
public struct LatLng
{
public double Lat { get; set; }
public double Lng { get; set; }
Expand All @@ -31,9 +31,15 @@ public override string ToString()
}
}

public class Point2d
public struct Point2d
{

public Point2d(long x, long y)
{
X = x;
Y = y;
}

public long X { get; set; }
public long Y { get; set; }

Expand Down
4 changes: 4 additions & 0 deletions src/Geometry/Geometry.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>..\..\bin\</OutputPath>
Expand All @@ -30,6 +31,7 @@
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -39,6 +41,7 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>..\..\bin\</OutputPath>
Expand All @@ -48,6 +51,7 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
Expand Down
Loading