NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

[netcdfgroup] strlen calls in NC_finddim and NC_findvar

I have a monstrous file with several thousand dimensions and variables which is running slower than it should. I investigated the runtime and found that strlen was the major time user in the NC_finddim and NC_findvar calls. The obvious optimization was to cache the length of the name instead of calling strlen each time. However, when I went to do this, I discovered that the length is already cached as the nchars field in the NC_string struct.

I did some checks in the code and also added some assertions to the code and verified that, as far as I can tell, nchars is the correct length of the string. Is there a reason that it isn't used and strlen() is called instead? Switching the code to use nchars dropped my execution time from 20 units to 6 units. I would like to make the switch, but wondered if there was some strange corner case where the nchars value is incorrect and will cause problems.

Thanks,
--Greg



  • 2009 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: