@echo off:: Add the paths for the F# SDK 3.x (from higher version to lower)setFSHARPSDK=^
C:\Program Files(x86)\Microsoft SDKs\F#\3.1\Framework\v4.0\;^
C:\Program Files(x86)\Microsoft SDKs\F#\3.0\Framework\v4.0\
cls:: Execute the script "only" with the first "fsianycpu.exe" foundfor%%iin(fsianycpu.exe)do"%%~$FSHARPSDK:i"DG.StressTest.Browser.fsx %*pause
(* nuget install -ExcludeVersion canopy *)#r@"Selenium.Support\lib\net40\WebDriver.Support.dll"#r@"Selenium.WebDriver\lib\net40\WebDriver.dll"#r@"canopy\lib\canopy.dll"#load@"DG.Auth.fsx"(* Just contains let usr = "usr" and let pwd = "pwd" *)openSystemopenSystem.IOopencanopyopenrunneropenconfiguration(* Config canopy *)compareTimeout<-30.0(* Utils *)lettimestamp()=DateTime.Now.ToString("o").Replace(":","")lettimestamp'()=DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")letstring2float=function|(n,s)->matchDouble.TryParseswith|true,value->value*n|_->0.letparse(s:string)=matchswith|mswhens.Contains("ms")->1.,ms.Replace(" ms","")|KBwhens.Contains("KB/sec")->1.,KB.Replace(" KB/sec","")|MBwhens.Contains("MB/sec")->1000.,MB.Replace(" MB/sec","")|_->failwith"Not recognized unit"|>string2float|>int(* Local files / folders *)letoutput=@"./output.csv"letsource=@".source/"(* Connection info: *)leturiMain=Uri(@"https://org.crm4.dynamics.com");leturiDiag=Uri(uriMain.AbsoluteUri+@"/tools/diagnostics/diag.aspx")(* Save to .source folder *)letsave2sourcedata=File.WriteAllText(source+timestamp()+".log",data)(* Browser Performance Test MS CRM Online *)letrecperformanceTestCrmdatepath=match(date>DateTime.Now)with|true->click"#runBtn_all"waitFor(fun()->(read"#td_status_all")="complete")save2source(read"#resultConsole")letlatency,speed,jsArray,jsMorph,jsBase64,jsDOM=parse(read"#td_result_latency"),parse(read"#td_result_bandwidth"),parse(read"#td_result_jsArrayBenchmark"),parse(read"#td_result_jsMorphBenchmark"),parse(read"#td_result_jsBase64Benchmark"),parse(read"#td_result_jsDomBenchmark")letsw=File.AppendText(path)sw.WriteLine(sprintf"%s;%i;%i;%i;%i;%i;%i;"(timestamp'())latencyspeedjsArrayjsMorphjsBase64jsDOM)sw.Dispose()reload()performanceTestCrmdatepath|false->()(* Start Browser Response Test: *)startchrome"MS CRM Online Browser Performance Test"&&&fun_->(* Clear output.csv and .source folder *)File.Exists(output)|>function|true->File.Delete(output)|false->()Directory.EnumerateFiles(@".source","*.log",SearchOption.AllDirectories)|>Seq.iter(funx->File.Delete(x))(* Go to MS CRM Online *)urluriMain.AbsoluteUri(* Login *)"#cred_userid_inputtext"<<DG.Auth.usr"#cred_password_inputtext"<<DG.Auth.pwdclick"#cred_sign_in_button"pressenter(* Go to diag url *)urluriDiag.AbsoluteUri(* Start and Stop DateTimes *)letstartDate=DateTime.NowletstopDate=startDate.AddMinutes(60.)letsw=File.CreateText(output)sw.WriteLine("Timestamp (ISO 8601);Latency (ms);Speed (KB/sec);"+"JS Array (ms);JS Morph (ms);JS Base64 (ms);JS DOM (ms);")sw.Dispose()performanceTestCrmstopDateoutputrun()quit()
Code result:
Starting ChromeDriver (v2.10.267521) on port 64015
Only local connections are allowed.
Test: Browser Performance Test MS CRM Online
Passed
60 minutes 19 seconds to execute
1 passed
0 failed
Press any key to continue . . .
Code result (.source\2014-09-18T225959.2540079+0200.log):
=== Latency Test Info ===
Number of times run: 20
Run 1 time: 46 ms
Run 2 time: 51 ms
Run 3 time: 48 ms
Run 4 time: 47 ms
Run 5 time: 48 ms
Run 6 time: 45 ms
Run 7 time: 46 ms
Run 8 time: 46 ms
Run 9 time: 46 ms
Run 10 time: 52 ms
Run 11 time: 50 ms
Run 12 time: 47 ms
Run 13 time: 47 ms
Run 14 time: 45 ms
Run 15 time: 44 ms
Run 16 time: 47 ms
Run 17 time: 48 ms
Run 18 time: 48 ms
Run 19 time: 45 ms
Run 20 time: 50 ms
Average latency: 47 ms
Client Time: Thu, 18 Sep 2014 20:59:57 GMT
=== Bandwidth Test Info ===
Run 1
Time: 56 ms
Blob Size: 15180 bytes
Speed: 264 KB/sec
Run 2
Time: 49 ms
Blob Size: 15180 bytes
Speed: 302 KB/sec
Run 3
Time: 50 ms
Blob Size: 15180 bytes
Speed: 296 KB/sec
Run 4
Time: 49 ms
Blob Size: 15180 bytes
Speed: 302 KB/sec
Run 5
Time: 51 ms
Blob Size: 15180 bytes
Speed: 290 KB/sec
Run 6
Time: 51 ms
Blob Size: 15180 bytes
Speed: 290 KB/sec
Run 7
Time: 52 ms
Blob Size: 15180 bytes
Speed: 285 KB/sec
Run 8
Time: 52 ms
Blob Size: 15180 bytes
Speed: 285 KB/sec
Run 9
Time: 50 ms
Blob Size: 15180 bytes
Speed: 296 KB/sec
Run 10
Time: 53 ms
Blob Size: 15180 bytes
Speed: 279 KB/sec
Max Download speed: 302 KB/sec
Client Time: Thu, 18 Sep 2014 20:59:58 GMT
=== Browser Info ===
Browser CodeName: Mozilla
Browser Name: Netscape
Browser Version: 5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36
Cookies Enabled: true
Platform: Win32
User-agent header: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36
Client Time: Thu, 18 Sep 2014 20:59:58 GMT
=== Machine Info ===
Client IP Address: XXX.XXX.XXX.XXX
Client Time: Thu, 18 Sep 2014 20:59:58 GMT
=== Array Manipultaion Benchmark ===
Time: 229 ms
Client Time: Thu, 18 Sep 2014 20:59:58 GMT
=== Morph Benchmark ===
Time: 33 ms
Client Time: Thu, 18 Sep 2014 20:59:58 GMT
=== Base 64 Benchmark ===
Time: 5 ms
Client Time: Thu, 18 Sep 2014 20:59:59 GMT
=== DOM Benchmark ===
Total Time: 13 ms
Breakdown:
Append: 3ms
Prepend: 5ms
Index: 0ms
Insert: 4ms
Remove: 1ms
Client Time: Thu, 18 Sep 2014 20:59:59 GMT
=== Organization Info ===
Organization name: orgSomeIdNumber
Is Live: True
Server time: 9/18/2014 8:59:55 PM UTC
Url: https://org.crm4.dynamics.com//tools/diagnostics/diag.aspx
Client Time: Thu, 18 Sep 2014 20:59:59 GMT