Friday, August 07, 2009

I'm back

I've been off for some time, I has been working on both the university and this great game we are creating at gasp, check out the trailer:



I will be working on the console a little these days, fixing bugs like garbage generation and optimizing it in general, also I'll improve the python interpreter and add some scripts to do useful stuff.

JG

Wednesday, May 20, 2009

The new stuff didn't come so soon, did it?
I'm sorry but I just haven't got the time to finish tweaking some minor details. I'll finish this release and upload as soon as I have some free time. The work and the university have been very time consuming these days.

JG.

Friday, March 20, 2009

New stuff coming very soon.
  • Integrated python interpreter, thanks to Samuel Christie
  • Some useful scripts to trace variables
  • Mouse controller sliders to tweak your variables on runtime
  • Logging
  • A lot more
Stay tuned.

JG

Tuesday, March 10, 2009

Debug Console - Second Release

Hello, I fixed a lot of issues I had with the console I didn't know about.
  • I'm now using the same effect (an instance of XNA's BasicEffect) for every component.
  • Lines are now traceable. That is, each line you draw have a name, then when you draw a line with the same name, the previous line gets moved.
  • Some of you might had problems with the ShowLine and ShowMark methods, fixed.
  • I have created a new command parser in order to add scalability. You can now for example use Game1.console.Execute("trace Player1.position", position); and would be the same as using Game1.console.Show("Player1.position", position);. This is because later I will add the feature to trace values in runtime, something that will decrease debugging time for your games.
Things I need to fix:
  • console.DrawBox
  • console.Log
  • Test it on the XBOX
The code is now commited. and here's the .dll library

JG

Monday, March 09, 2009

LINQ Benchmark fixed.
I posted about the benchmark in the Creators Club forums and they explained me why these results were incorrect. I measured it wrong.
The thing is that on the LINQ test I wasn't actually running the query. To run it, I must at least iterate over the result, this is because the defered execution of the IEnumerable implementation, and the return yield it runs.

So I rewrote it, and the results came out more predictable, here you have them.

I also increased the valueCount to a hundred million values. And there you have it, even though LINQ version is more elegant, it took almost twice the time, so for time critical operation I would prefer avoiding it.

JG

Thursday, March 05, 2009

LINQ Benchmark

For those of you that doesn't know LINQ yet, it's a new technology from c# 3.0 that lets you run queries independently from your database, even on c# objects (like arrays, List, LinkedList, etc) with a SQL-like statement .

Yesterday I was wondering how fast LINQ could run some queries compared to more traditional methods. I'm not talking about LINQ to SQL on an external database, but running a query on some IEnumerable object instead. So I created a small benchmark. I'm not sure if it is correct because there is some stuff that I might be timing erroneously, so please tell me if I should be considering things like JIT time, GC, or any other housekeeping.

Anyway, on a very simple test the results came out unexpectedly.

Here's the method I wrote:



static void Main(string[] args)
{
int valueCount = 1000000;
Random random = new Random();
float[] values = new float[valueCount];

Stopwatch timer;
// Initialize the values
for (int i = 0; i < valueCount; i++)
{
values[i] = random.Next(valueCount);
}
GC.Collect();


// LINQ
Console.WriteLine("Try with the LINQ query");
timer = Stopwatch.StartNew();
IEnumerable<float> extracted1 = from v in values where v < 500000 select v;
timer.Stop();
Console.WriteLine(timer.Elapsed.TotalSeconds);
Console.ReadLine();

// Regular for
Console.WriteLine("Try with the 'for' iteration");
List<float> extracted2 = new List<float>();
timer = Stopwatch.StartNew();
float var;
for (int i = 0; i < valueCount; i++)
{
var = values[i];
if (var < 500000)
extracted2.Add(var);
}
timer.Stop();
Console.WriteLine(timer.Elapsed.TotalSeconds);
Console.WriteLine(String.Format("Counts: {0}, {1}", extracted1.Count(), extracted2.Count()));
Console.ReadLine();
}

It creates an array of random values ranging from 0 up to 1 million. Then both tests try to extract 500000 numbers from the values given the simple rule (x < 500000). So here are the results:

This is one of the results I got. LINQ was 50 times faster??? Am I measuring this wrong?

JG

Saturday, February 21, 2009

Hey ya, next week I have planned to add the Log method, so you can keep a historical log of the runtime. Plus, i'll fix some minor bugs.
Another thing I should begin to care is "threadsafeness", because sometimes calling methods from different threads can cause consistency problems.

JG