Am 24.12.2012 00:08, schrieb Patrick Walton:
On 12/23/12 5:53 PM, Michael Neumann wrote:
That's strange. If I use result::unwrap() it is consistently becoming
much slower! But the warning goes away. While get() is faster, but
there is this warning. Btw, there is also no .unwrap(), just
result::unwrap(). I believe that unwrap() is copying, while get() is
passing a reference somehow.

This is not what I see. This program:

    fn f() -> Result<~str,~str> {
        Ok(~"hello world")
    }

    fn main() {
        for uint::range(0, 0x1234567) |_| {
            let _ = f().get();
        }
    }

Has this performance:

    real    0m15.991s
    user    0m15.899s
    sys    0m0.016s

While this program:

    fn f() -> Result<~str,~str> {
        Ok(~"hello world")
    }

    fn main() {
        for uint::range(0, 0x1234567) |_| {
            let _ = result::unwrap(f());
        }
    }

Has this performance:

    real    0m4.318s
    user    0m4.255s
    sys    0m0.013s

I now see the same behaviour when I measure result::unwrap vs .get().
Hm, I think my benchmark was just flawed because it run under a VM on a laptop.

Michael
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to