High Performance Timing
A lot of times we need to know how long a process takes. The simple way to do this is dim startDate as DateTime = DateTime.Now
' do work
dim elapsed as TimeSpan = startDate.Subtract(DateTime.Now)
Console.WriteLine(elapsed.TotalMilliseconds)
For a general sense of time this works fine but this is not entirely accurate. DateTime.Now pulls from a lower frequency clock and can be off by milliseconds (or more).
To use a highly accurate timing MS introduced the stopwatch class in .NET 2.0. This class polls the high frequency clock to get accurate timings:
dim timer as Stopwatch = Stopwatch.StartNew
'do work
timer.Stop()
console.WriteLine(timer.ElapsedMilliseconds)
Another thing you can...
Iterative Hashing: Less Secure Is More Secure (in theory)
*DISCLAIMER: This is only a theoretical idea. I have not confirmed that this could increase security of an iterative hash. Please take that into account when reading this. I was explaining iterative hashing the other day and came up with an interesting theory: Using a weak algorithm may result in a stronger hash. The reason for this is collisions that can happen in algorithms like SHA0, SHA1, and MD5 (a collision is when two separate strings yield the exact same hash). By using a collisionable algorithm in an iterative hash we could potentially throw an attacker way off. ...
Things I Can’t Develop Without: Source Control
Source control is such a crucial tool that I will not develop without that I forgot about it when doing the “Thing’s I Can’t Develop Without” series. For those of you that have never heard of source control (most people have but just in case you have not). It is a simple tool that allows you to check in code to a central repository that records your changes. This allows for several nice features. Versioning. You can easily view or rollback to old versions of code. This allows us to change or delete...
Announcing My New Open Source Project: Fluent Build
I have created a fluent interface around doing builds, allowing users to write build scripts in a simple and terse manner. The project is hosted at http://code.google.com/p/fluent-build/ It is just the start of the project but thought I would get it out there and get feedback earlier rather than later. Here is a sample build class: internal class MainBuildTask { private string directory_base; private string directory_compile; private string assembly_FluentBuild; private string assembly_FluentBuild_Tests; private string thirdparty_rhino; private string thirdparty_nunit; private string directory_tools; public void Execute() { directory_base = Environment.CurrentDirectory; directory_compile = directory_base.SubFolder("compile"); directory_tools = directory_base.SubFolder("tools"); assembly_FluentBuild =...