Created
June 23, 2014 19:13
-
-
Save ptrelford/c9d3433655f21f3dd561 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Start in VS: View -> Other Windows -> F# Interactive | |
open System | |
// Turn on timing in F# interactive | |
#time | |
// Performance bottle kneck | |
let formatKey (a:string,b:string) = | |
String.Format("{0}:{1}", a, b) | |
// Time it | |
for i = 1 to 1000000 do ignore(formatKey("aaa","bbb")) | |
// 5x faster version | |
let concatKey (a:string,b:string) = | |
String.Concat(a,":",b) | |
// Time it | |
for i = 1 to 1000000 do ignore(concatKey("aaa","bbb")) | |
open System.Collections.Generic | |
// Inserting at end of .Net List | |
let xs = List<int>() | |
for i = 1 to 1000000 do xs.Add(i) | |
// Inserting at start of .Net list | |
xs.Clear() | |
for i = 1 to 1000000 do xs.Insert(0,i) | |
// Wait 5 minutes... | |
// Or right click & Reset Interactive Session |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment