RegionManager.cs:
More extensive logging
This commit is contained in:
parent
f15171a9f1
commit
4f0d5d4f30
@ -45,18 +45,21 @@ namespace OSMImporter
|
|||||||
private Region LoadRegion(Coordinates coordinates)
|
private Region LoadRegion(Coordinates coordinates)
|
||||||
{
|
{
|
||||||
string fullPath = Path.Combine(workingDirectory, coordinates.GetRegionHash().ToString());
|
string fullPath = Path.Combine(workingDirectory, coordinates.GetRegionHash().ToString());
|
||||||
Console.WriteLine("Loading {0}", fullPath);
|
DateTime startTime = DateTime.Now;
|
||||||
if (!File.Exists(fullPath))
|
if (!File.Exists(fullPath))
|
||||||
{
|
{
|
||||||
throw new FileNotFoundException(string.Format("Region does not exist: {0}", fullPath));
|
throw new FileNotFoundException(string.Format("[{0}] Region does not exist: {1}", startTime, fullPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
FileStream fileStream = new FileStream(fullPath, FileMode.Open);
|
FileStream fileStream = new FileStream(fullPath, FileMode.Open);
|
||||||
|
long fileStreamLength = fileStream.Length;
|
||||||
|
Console.WriteLine("[{0}] Loading [{1}]bytes from {2}", startTime.ToLocalTime(), fileStreamLength, fullPath);
|
||||||
|
|
||||||
byte[] regionBytes = new byte[fileStream.Length];
|
byte[] regionBytes = new byte[fileStream.Length];
|
||||||
int _ = fileStream.Read(regionBytes, 0, regionBytes.Length);
|
int loadedBytesLength = fileStream.Read(regionBytes, 0, regionBytes.Length);
|
||||||
fileStream.Close();
|
fileStream.Close();
|
||||||
|
|
||||||
|
Console.WriteLine("\tLoaded [{0}]bytes ({1:P1}) in [{2}]ms", loadedBytesLength, fileStreamLength / loadedBytesLength,DateTime.Now.Subtract(startTime).TotalMilliseconds);
|
||||||
return ByteConverter.ToRegion(regionBytes);
|
return ByteConverter.ToRegion(regionBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user