with i32 for rust:
(I am on x86_64)

==> vector_grow_c.csv <==
1000000000,4.741286

==> vector_grow_rust.csv <==
1000000000,3.147506

==> vector_grow_rust2.csv <==
1000000000,3.153482

On Thu, Sep 25, 2014 at 9:30 PM, Clark Gaebel <cg.wowus...@gmail.com> wrote:
> Another problem I noticed is that the elements in the vector in the rust
> code are `uint` (which on most systems is 64-bit) and in the C code you’re
> inserting `int`s (32-bits on most systems).
>
> That’s not really a fair contest.
>
>   - Clark
>
>
>
> On Thu, Sep 25, 2014 at 6:26 PM, François-Xavier Bourlet <bomb...@gmail.com>
> wrote:
>>
>> and hitting reply-all is better...
>>
>> quick update: the implementation with unsafe & ptr is not slower. I
>> just have too many cores + power-boost to get a clean benchmark every
>> time.
>> Running the benchs with n=1 billions (instead of 100 millions) gives me:
>>
>>
>> ==> vector_grow_c.csv <==
>> 1000000000,5.084604
>>
>> ==> vector_grow_rust.csv <==
>> 1000000000,5.217096
>>
>> ==> vector_grow_rust2.csv <==
>> 1000000000,4.912147 (yes, getting rid of the second push works!)
>>
>> $ rustc --version
>> rustc 0.12.0-pre-nightly (0e784e168 2014-09-16 23:26:11 +0000)
>> $ gcc --version
>> gcc (GCC) 4.9.1
>>
>> On Thu, Sep 25, 2014 at 6:18 PM, François-Xavier Bourlet
>> <bomb...@gmail.com> wrote:
>> > On my machine I get:
>> >
>> > C: 100000000,0.509391
>> > rust: 100000000,0.466069
>> >
>> > So rust is faster for me.
>> >
>> > For fun, I tried to write the rust version using unsafe and
>> > pre-allocation to remove the second push:
>> >
>> > let mut m = Vec::from_fn(101, |_| 0);
>> > let pm = m.as_mut_ptr();
>> > let mut m_idx = 1i;
>> > let t = time::precise_time_ns();
>> > for _i in iter::range_step(0, n, n/100) {
>> > for j in range(0, n/100) {
>> > v.push(j);
>> > }
>> > unsafe {
>> > ptr::write(pm.offset(m_idx as int), time::precise_time_ns() - t);
>> > }
>> > m_idx += 1;
>> > }
>> >
>> > But I get a little slower result (maybe I am doing something wrong
>> > with the unsafe and ptr):
>> > rust2: 100000000,0.472749
>> >
>> > And just to be sure, I tested getting rid of iterators (using manual
>> > while loop instead) and this changed nothing (as expected).
>> >
>> > my 2 cents
>> >
>> >
>> > On Thu, Sep 25, 2014 at 4:05 PM, Clark Gaebel <cg.wowus...@gmail.com>
>> > wrote:
>> >> You’re also timing two pushes, as opposed to a push and an array write
>> >> in
>> >> the C version.
>> >>
>> >>
>> >>
>> >> On Thu, Sep 25, 2014 at 3:59 PM, Daniel Micay <danielmi...@gmail.com>
>> >> wrote:
>> >>>
>> >>> <signature.asc>
>> >>
>> >>
>> >>
>> >> _______________________________________________
>> >> Rust-dev mailing list
>> >> Rust-dev@mozilla.org
>> >> https://mail.mozilla.org/listinfo/rust-dev
>> >>
>
>
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to