NuGet Snippet:
Script Snippet (DG.StressTest.Browser.cmd):
Code Snippet (DG.StressTest.Browser.fsx):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
| (* 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" *)
open System
open System.IO
open canopy
open runner
open configuration
(* Config canopy *)
compareTimeout <- 30.0
(* Utils *)
let timestamp () = DateTime.Now.ToString("o").Replace(":","")
let timestamp' () = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
let string2float = function
| (n,s) -> match Double.TryParse s with | true, value -> value * n | _ -> 0.
let parse (s:string) =
match s with
| ms when s.Contains("ms") -> 1., ms.Replace(" ms","")
| KB when s.Contains("KB/sec") -> 1., KB.Replace(" KB/sec","")
| MB when s.Contains("MB/sec") -> 1000., MB.Replace(" MB/sec","")
| _ -> failwith "Not recognized unit"
|> string2float |> int
(* Local files / folders *)
let output = @"./output.csv"
let source = @".source/"
(* Connection info: *)
let uriMain = Uri(@"https://org.crm4.dynamics.com");
let uriDiag = Uri(uriMain.AbsoluteUri + @"/tools/diagnostics/diag.aspx")
(* Save to .source folder *)
let save2source data =
File.WriteAllText(source + timestamp() + ".log", data)
(* Browser Performance Test MS CRM Online *)
let rec performanceTestCrm date path =
match (date > DateTime.Now) with
| true ->
click "#runBtn_all"
waitFor (fun () -> (read "#td_status_all") = "complete")
save2source (read "#resultConsole")
let latency, 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")
let sw = File.AppendText(path)
sw.WriteLine(
sprintf "%s;%i;%i;%i;%i;%i;%i;"
(timestamp'()) latency speed jsArray jsMorph jsBase64 jsDOM)
sw.Dispose()
reload()
performanceTestCrm date path
| false -> ()
(* Start Browser Response Test: *)
start chrome
"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(fun x -> File.Delete(x))
(* Go to MS CRM Online *)
url uriMain.AbsoluteUri
(* Login *)
"#cred_userid_inputtext" << DG.Auth.usr
"#cred_password_inputtext" << DG.Auth.pwd
click "#cred_sign_in_button"
press enter
(* Go to diag url *)
url uriDiag.AbsoluteUri
(* Start and Stop DateTimes *)
let startDate = DateTime.Now
let stopDate = startDate.AddMinutes(60.)
let sw = 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()
performanceTestCrm stopDate output
run()
quit()
|
Code result:
Code result (output.csv):
Code result (.source\2014-09-18T225959.2540079+0200.log):
Chart diagrams:
Architecture (Lenovo ThinkPad W540):