0

Under nodejs the hdf5 code below takes about 200 milliseconds to run.

hdf5 = require('hdf5').hdf5;
h5lt = require('hdf5').h5lt;
Access = require('hdf5/lib/globals').Access;
start = new Date();
f = new hdf5.File('myhdf5file', Access.ACC_RDONLY);
h5lt.readDataset(f.id, 'Timestamp');
console.log(new Date() - start);

Similar code in python takes about 1 millisecond.

import h5py
from datetime import datetime
start = datetime.now()
h5py.File('myhdf5file')['Timestamp']
print datetime.now() - start

What would explain such a big difference? The hdf5 file is about 2 megs in size. I'm running on Linux.

Greg Clinton
  • 365
  • 1
  • 7
  • 18
  • Did you try to profile the code? Typically you can't compare different packages across programming languages except these packages wrap the same source code. The `hdf5` package on nodejs could be simply less mature? – MSeifert Mar 04 '17 at 01:13
  • @MSeifert, I wouldn't know how to profile it. I thought both languages would use the same c libs underneath. So the difference in speed really surprised me. – Greg Clinton Mar 04 '17 at 01:26
  • [Easy profiling for Node.js Applications](https://nodejs.org/en/docs/guides/simple-profiling/) and [The Python Profilers](https://docs.python.org/3.6/library/profile.html). Using `Date` or `datetime` is probably too inexact to time, there are specialized timing libraries: [Python - Measure execution time of small code snippets](https://docs.python.org/3.6/library/timeit.html) and I guess there is also some library for node.js. I heard of `process.hrtime()`, maybe that's feasible. – MSeifert Mar 04 '17 at 01:40
  • 1
    That `h5py` code opens the file and accesses a group or series, but I don't think it actually loads any data. – hpaulj Mar 04 '17 at 03:02
  • Both languages use a wrapper around the same complied HDF5 C++ code (possibly different releases). – hpaulj Mar 04 '17 at 04:14

0 Answers0