Results 1 to 1 of 1
-
16th Oct 2017, 12:16 PM #1
[C#] Speed Test snippet
Speed Test snippet
Code:using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Net; namespace SpeedTest { class Program { static void Main(string[] args) { try { //tricky output lol double Speed_test1 = get_speed(); double Speed_test2 = get_speed(); double Speed_test3 = get_speed(); double Speed_test4 = get_speed(); double Speed_test5 = get_speed(); double Speed_test6 = get_speed(); double Speed_test7 = get_speed(); double Speed_test8 = get_speed(); double Speed_test9 = get_speed(); double Speed_test10 = get_speed(); double average = (Speed_test1 + Speed_test2 + Speed_test3 + Speed_test4 + Speed_test5 + Speed_test6 + Speed_test7 + Speed_test8 + Speed_test9 + Speed_test10) / 10; double megabytes2 = (long)average; double megabytes = ConvertKilobytesToMegabytes((long)megabytes2); Console.WriteLine("Speed Test Average" + Environment.NewLine + megabytes + Environment.NewLine + "Mbps"); Console.ReadKey(); } catch { } } static double ConvertKilobytesToMegabytes(long kilobytes) { return kilobytes / 1024f; } private static Double get_speed() { // the URL to download a file from Uri URL = new Uri("http://localhost/bootstrapable/bot_cms/1024kb.txt"); WebClient wc = new WebClient(); string drivepath = Path.GetPathRoot(Environment.SystemDirectory); // get current tickcount double starttime = Environment.TickCount; // download file from the specified URL, and save it to a temp path etc not c as virus doesnt depend on c drive assumption bad parctice to do wc.DownloadFile(URL, drivepath + "\\" + "speedtest.txt"); double endtime = Environment.TickCount; double secs = Math.Floor(endtime - starttime) / 1000; double secs2 = Math.Round(secs, 0); double kbsec = Math.Round(1024 / secs); try { // delete downloaded file System.IO.File.Delete(drivepath + "\\" + "speedtest.txt"); } catch { } return kbsec; } } }
Kevin Reviewed by Kevin on . [C#] Speed Test snippet Speed Test snippet using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Net; namespace SpeedTest { Rating: 5
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 6 users browsing this thread. (0 members and 6 guests)
Vn5socks.net 21-11-2024 | socks 5...
Live | 107.180.107.116:41716 | United States |...