#24 Performance improvements to ctype interface

open
Tom
None
5
2008-02-26
2008-02-04
Tom
No

(The following results are with FreeMat 3.5)

Using the attached readtest.m and writetest.m files, I got the following results for the reading/writing of 200 copies of a rather large structure (64 fields, 1K floats per field):

- reading the data using fread took ~ 0.16 secs
- reading the data using ctyperead took ~ 0.69 secs
- writing the data using fwrite took ~ 0.25 secs
- writing the data using ctypewrite took ~ 1.35 secs

The attached patches make the following changes:

- modify the Malloc interface to take a flag determining whether or not memory is set to zero. Do not set memory to zero in fread() and some of the allocations in the ctype interface where we know the memory will be overwritten.
- use character arrays rather than the QBtyeArrays. The QByteArray constructor showed up fairly high in the timings.
- use memcpy when possible (mostly in place of the QByteArray at() method)

With those modifications, the timings are as follows:

- reading the data using fread took ~ 0.12 secs
- reading the data using ctyperead took ~ 0.29 secs
- writing the data using fwrite took ~ 0.25 secs
- writing the data using ctypewrite took ~ 0.45 secs

(the fread changes are due to changing to the non-zeroing Malloc call -- fread() is also used by ctyperead())

Discussion

  • Tom

    Tom - 2008-02-04

    fread/ctyperead timing test

     
  • Tom

    Tom - 2008-02-04

    Logged In: YES
    user_id=1619785
    Originator: YES

    File Added: writetest.m

     
  • Tom

    Tom - 2008-02-04

    fwrite/ctypewrite timing test

     
  • Tom

    Tom - 2008-02-04

    Logged In: YES
    user_id=1619785
    Originator: YES

    The attached patch patches a few files. Applying with -p1 in libs/ should work. I can generate a patch against SVN if needed.
    File Added: ctype-perf.patch

     
  • Tom

    Tom - 2008-02-04

    patch; apply with -p1 in the libs/ directory

     
  • Demetrios Kyriakis

    • assigned_to: nobody --> thomasbenson
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks