Introduction
I like to write software as a bit of a hobby. I use Microsoft C# Visual Studio and have written a small number of (Windows) applications for my own use. These are always a "work in progress" and each application uses code from previous applications
My latest application is a Windows application wrapper around the Ookla Speedtest CLI application (I know there is an official Ookla Windows application here) but where's the fun in that? Has mixed reviews on the Windows Store as well to be honest.
Ookla (here) do the internet speed tester. The reason for this was that recently we moved from ADSL (copper wire) broadband (at typically 30-50Mbps) to BT full fibre at 500Mbps and I obviously wanted to check I was getting what I paid for
The initial tests using the web page version showed that at times I was getting 500Mbps download but this was very variable (I was not rigorous enough to test whilst ensuring no other devices were using the internet). Upload speeds were very consistent at about 70Mbps.
Here's an example:
What I could not tell reliably was how did this vary and by what amount. I decided that what I'd do was put a Windows wrapper wound the Ookla CLI version
This can be downloaded from here:
This page describes the software that I wrote
The Code
In this case I also took some time to prepare a proper class library - I have quite a few classes that I re-use (these are: an SQL database class, an application logger class, a general utilities class, a DataTable handling class, a Process Class and a few other miscellaneous classes). I realised that my existing method of copying the last version of the class to the new project did not work and I never copied the updates back. Now that I have a Class Library, this is a much better solution and I used it on a 2nd project at the same time (this was to address some database creation issues I had) and the code worked for both projects.
It took some effort to work out how to do this - for example I had not realised that it was a "code only" class and and Windows forms (for example) could not be included. I am assuming that I can create a Windows forms class library. In terms of the SQL code I spent a lot of time trying to simplify the code and break up into smaller classes with some inherited behaviour. This has improved the code but it needs more work
I run the speed test by spawning it as a Process, intercepting the STDOUT and parsing it (this
I also wanted the application to be responsive during the speed test - once the Process class started the execution the application hung until the test was completed - for up to 25-30 seconds. This was not good. To fix this I used a background worker thread (actually I used 2 - one for the speed test and the other to monitor completion and allow aborting the test). This was a new area of code for me. Using these background worker threads showed another issue that this was a sperate thread so I could not get results or interact - this was fixed with creating some delegates to update a DataGridview, update progress bars etc. Not quite sure what delegates do (I need to do some more reading) but it works. Thanks to Stackoverflow for all this.
Installing the software
Before you install this application you need to down load the Ookla Windows CLI file from here. Download and extract the exe file to a location of your choice
You can test the code manually if you like. Open a Command prompt, change directory to the location of speedtest.exe and type speedtest.exe.
Note that the first time you run the Ookla CLI application it asks you to accept the licence terms and GPDR terms. My application checks if this has been already done. If it has it moves on, if it has not it accepts them on your behalf.
My application is here on my Google drive. Download and extract the zip file to get the installer:
To look at the database folder use the Miscellaneous menu:
[Database_Properties]Database_Path=C:\Users\<User>\AppData\Local\Speed_TestDatabase_Name=Speed_Test[Executable_Properties]Executable_Path=L:\Visual Studio\Speed_Test\Speed_Test\bin\DebugExecutable_Name=speedtest.exe[Log_Properties]Log_Path=C:\Users\<User>\AppData\Local\Speed_TestLog_Name=log.txt[Timer_Properties]Timer_Value=30000
No comments:
Post a Comment