« first day (348 days earlier)      last day (345 days later) » 

11:53 AM
I'm doing some performance check between lists in C# and in F# to see if there are big differences
But I think my test is wrong
 
Where?
 
Since in C# I'm using the .NET List
 
Where are you doing the check?
 
open System
let sw = System.Diagnostics.Stopwatch()
sw.Start()

for i in 1 .. 100000 do
    [0..10000]
    |> List.map (fun x -> x * 2)
    |> List.sum

sw.Stop()
printfn "%A" sw.Elapsed

sw.Reset()
Is that what you asked? :X
That takes 2 minutes to run...
 
No.
Are you doing it in vs?
 
11:55 AM
Yes, in VS 2010 :X
I don't have 2013 here with me
Why ?
 
Oh, never mind...
So, you're evaluation the performance of map and sum?
 
Yeah, forget about the sum actually
This is what I'm running against
            var sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            for (var teste = 0; teste < 100000; teste++)
            {
                var list = new System.Collections.Generic.List<int>();

                for (var i = 0; i <= 10000; i++)
                    list.Add(i);

                list.ForEach(f => f *= 2);
            }
            sw.Stop();
            System.Console.WriteLine(sw.Elapsed.ToString());
            System.Console.ReadKey();
            sw.Reset();
 
i umm...
 
I think it is unfair to run .NET List against native F# List
 
And which one is faster?
 
12:00 PM
C# goes in 00:00:14.0826488
F# goes in 00:02:14.8949781
But, in math calculations, F# wins ridiculously
This is what I logged
[Loop 100.000]
[Loop 100.000]
[loop ( index + 5 ) * 2]
C# - 00:00:23.6366723 -
F# - 00:00:00.0000023 +
Loop inside a loop and the math ( index + 5 ) * 2
But nonetheless, I want to run a fair benchmark between collections
 
Oh... oh..
Map creates a new collection
open System
let sw = System.Diagnostics.Stopwatch()
let myList = [0..10000]
sw.Start()

for i in 1 .. 100000 do
    List.map ( fun x -> x * 2 ) myList

sw.Stop()
printfn "%A" sw.Elapsed

sw.Reset()
Ok, now it is amazingly fast
 
Umm, you're filling the list every time in c#...
i mean mod your c# to do the same.
 
Okay :X
let myList = [0..10000]

for i in 1 .. 100000 do
    List.map ( fun x -> x * 2 ) myList
            var list = new System.Collections.Generic.List<int>();
            for (var i = 0; i <= 10000; i++)
                list.Add(i);

            for (var teste = 0; teste < 100000; teste++)
                list.ForEach(f => f *= 2);
Pretty much the same thing right ?
 
12:17 PM
Well... ForEach is void.
 
Where ?
 
The method is void, it doesn't create a new list...
map does.
afaict
 
But that is in the .NET framework
 
You're not using the framework?
 
I am using.
But in F# I'm using the F# Core to the list
 
12:28 PM
        var l1 = new List<int>();
        l1.AddRange(Enumerable.Range(0, 10000));
        for (int i = 0; i < 100000; i++)
        {
            var l2 = new List<int>();
            l2.ForEach(f => l2.Add(f * 2));
        }
The way i understand it...
And that takes an hour to complete...
So i must be wrong.
lmao
i actually copy/pasted that from vs, so, yeah... i'm an idiot...
 
Damn typos.
Umm...
It was right before, wasn't it...
 
Damn this is really weird. F# has some slow Lists, but I'm probably doing something wrong
 
So...
 
Oh, yeah it was right before
 
12:33 PM
Ugh...
 
The l1 is useless in that way
 
So, don't you think that is about equivalent?
 
And l2 is always doing nothing too
 
i mean pre-edit.
 
Yeah I think
let myList = [0..10000]

for i in 1 .. 100000 do
    List.map ( fun x -> x * 2 ) myList
 
12:34 PM
Well, it's crazy slow.
 
Versus
var l1 = new List<int>();
l1.AddRange(Enumerable.Range(0, 10000));
for (int i = 0; i < 100000; i++)
{
    var l2 = new List<int>();
    l1.ForEach(f => l2.Add(f * 2));
}
 
Took about 10 seconds here...
 
And not quite similar..
12 seconds with me
 
How long does F# take?
 
Because in F# it is always creating the same 10k list with different values
13 seconds
But still, C# isn't doing the same
 
12:36 PM
Why not?
 
I think I'm not thinking correctly
Yeah my mistake, it is doing the same thing
 
i mean if map creates a new collection, this should be about equivalent...
So, performance difference is negligible then?
 
Well, 1 second difference between creating 100k lists that are 10k big...
 
Almost irrelevant haha
Yey F# ftw
 
 
5 hours later…
6:02 PM
@AndréSilva F# "list" is very different from List<T>
in F#, List<T> is called ResizeArray normally
the list in F# is immutable, so its going to have completely different performance characteristics
but you use it completely differently, too
if you want to compare, you could grab the immutable collections nuget package and use it from the C# side ;)
 
6:22 PM
So you're saying that if I use it correctly I'd have performance gain in the F# side ?
 
 
3 hours later…
8:56 PM
@AndréSilva Potentially - it depends a bit on what the algorithm is doing
just adding to lists is typically a bit slower than with List<T>, though, because it's got a bit higher memory allocations
so you'd normally use ResizeArray (List<T>) or something like Vector from the extras libs
 
 
1 hour later…
9:59 PM
hi guys
 
Hi @NickL
 
why doesn't this room have more people?
i thought FP was all the rage
 
I think it needs a bunch of regs first then hopefully it will get active and the rest will be easy
 
user1804599
10:15 PM
@NickL Because hipsters use Reddit and IRC.
 
user1804599
And FP users are mostly hipsters.
 
hah that's where i'll be going next then!
 
the F# IRC channel has a lot of people in it normally
but it's pretty quiet
 
11:05 PM
does anyone here use a predominantly functional language in their day job?
 
I use F# a lot - but I'm also using C++ and C# too
 
did you have to push to use F#?
 
11:22 PM
no - it's my company :)
so I get to push my developers to use it
 

« first day (348 days earlier)      last day (345 days later) »