MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: BinaryReadList with Mixed Types

  • To: mathgroup at smc.vnet.net
  • Subject: [mg92996] Re: BinaryReadList with Mixed Types
  • From: David Bailey <dave at Remove_Thisdbailey.co.uk>
  • Date: Wed, 22 Oct 2008 05:39:23 -0400 (EDT)
  • References: <gdkaiv$4pt$1@smc.vnet.net>

Raffy wrote:
> When BinaryReadList is used with mixed types like
> {"UnsignedInteger32", "Real32"}, the speed at which it imports is
> incredibly slow.
> 
> count = 10000;
> 
> file = OpenWrite["Slow.dat", BinaryFormat -> True];
> BinaryWrite[file,
>   Transpose@{RandomInteger[{0, 1}, count],
>     RandomReal[{0, 1}, count]}, {"UnsignedInteger32", "Real32"}];
> Close[file];
> 
> file = OpenWrite["Fast.dat", BinaryFormat -> True];
> BinaryWrite[file,
>   RandomReal[{0, 1}, {count, 2}], {"Real32", "Real32"}];
> Close[file];
> 
> BinaryReadList["Slow.dat", {"UnsignedInteger32", "Real32"}]; // Timing
> --- takes about 0.5 sec
> BinaryReadList["Fast.dat", {"Real32", "Real32"}]; // Timing --- a few
> ms at most
> 
> Is there anyway I can fix this performance?  The current speed is
> completely unacceptable.
> 
> Thank you.
> 
If nobody supplies a better solution, you could perform the binary read 
in Java (using J/Link) and arrange to pass the integers and reals back 
as separate arrays.

David Bailey
http://www.dbaileyconsultancy.co.uk


  • Prev by Date: How to reduce memory usage of the MathKernel.exe?
  • Next by Date: Re: Is there a simple way to transform 1.1 to 11/10?
  • Previous by thread: BinaryReadList with Mixed Types
  • Next by thread: Is there a simple way to transform 1.1 to 11/10?