Wednesday, 20 May 2009

Travian WorldMap Import Part 1

As previously mentioned, performance for Travian iMailer version 2 is paramount (+new features :))

Importing the Travian WorldMap file and processing means getting the file off the disk and into memory in a format that’s suitable for editing – unfortunately, the Travian servers perform an SQL dump and this uses a none standard line delimiter (none standard in the Windows world anyway), the LineFeed (LF), Windows uses LineFeedCarriageReturn (LFCR)

Loading the file into memory and splitting it by LF is very simple, but from a performance perspective, is there any different methodologies for this? well, yes.

In Visual Studio 2010 there are several methods. In testing I used a 3MB WorldMap file and preloaded it into cache so disk performance was removed from the calculations:-

  1. Slowest performance:- Using the built in Filesystem.ReadAllText (81ms)
  2. Almost as slow:- Using the built in Filesystem.ReadAllBytes and splitting it by LF (79ms)
  3. Fastest, specifically, twice as fast – Using the IO.StreamReader (40ms)

Does 40ms really matter; Yes, 302 servers = 12 seconds additional time; not major, but this is just one simple routine (read the file into memory for processing) and there are a lot of routines.

No comments:

Post a Comment

Feel free to leave comments for the Travian iMailer team