Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reads take approximately 10x longer than BDF.jl #50

Open
klaff opened this issue Oct 8, 2021 · 5 comments
Open

Reads take approximately 10x longer than BDF.jl #50

klaff opened this issue Oct 8, 2021 · 5 comments

Comments

@klaff
Copy link

klaff commented Oct 8, 2021

Using bdf_test.bdf file (https://github.com/beacon-biosignals/EDF.jl/blob/master/test/data/bdf_test.bdf) and the following MWE:

using BDF
using EDF
using BenchmarkTools

# BDF and EDF have very different APIs

get_ch1_using_BDF(fn) = readBDF(fn)[1][1,:]

get_ch1_using_EDF(fn) = EDF.decode(EDF.read(fn).signals[1])

test_filename = "bdf_test.bdf"

println("using BDF:")
@btime get_ch1_using_BDF(test_filename)
println("\nusing EDF:")
@btime get_ch1_using_EDF(test_filename)

I obtain the following:

using BDF:
  755.700 μs (305 allocations: 2.61 MiB)

using EDF:
  17.460 ms (146253 allocations: 2.87 MiB)

Hint: EDF is allocating once for every 3 bytes of data (this file has 24-bit data)

@ararslan
Copy link
Member

ararslan commented Oct 9, 2021

EDF is allocating once for every 3 bytes of data

Indeed, this seems to boil down to the read method from BitIntegers.jl allocating once per read. I'm not sure why just yet.

BDF.jl doesn't bother with maintaining the 24-bit on-disk representation and instead reads and converts directly to Int32, which does not incur any extra allocations.

@ararslan
Copy link
Member

I'm not sure why just yet.

Alignment padding

@likanzhan
Copy link
Contributor

Is it possible to speed up EDF?

@palday
Copy link
Member

palday commented Oct 26, 2021

@likanzhan The reading of EDF files should be fine -- it should only be BDF that's impacted. If there has been a change in performance for EDF between EDF.jl v0.6 and v0.7, then that would be good to know, especially if you can provide details on the file and platform.

@likanzhan
Copy link
Contributor

likanzhan commented Oct 27, 2021

@palday Thanks. Unfortunatly, the data format we obtained is "BDF+". The platform is a customized one, called Neuracle. To be specific, the data and the event information were stored in different files, i.e., data.bdf and evt.bdf. Here is one data we recorded. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants