develooper Front page | perl.perl6.users | Postings from June 2020

Re: Help converting CArray[uint8] to Blob

Thread Previous | Thread Next
From:
Elizabeth Mattijsen
Date:
June 17, 2020 17:11
Subject:
Re: Help converting CArray[uint8] to Blob
Message ID:
08D2B25A-1882-4CF2-84C3-D56C0AD7D796@dijkmat.nl
Shorter, and much more readable, I'd say:

    my Blob $blob = blob-from-carray($ed.data, size=>$ed.data_size);
    say "bindata =  { now - INIT now }";

The term "now" is short for "DateTime.now.Instant"

The INIT phaser is run when the program is started: it returns the value that was obtained from the code then executed.

Phasers for the win!


> On 17 Jun 2020, at 19:01, David Santiago <demanuel@gmail.com> wrote:
> 
> Super!
> 
> That what i was looking for, i changed the code to:
> 
> my Instant $init = DateTime.now.Instant;
> my Blob $blob = blob-from-carray($ed.data, size=>$ed.data_size);
> say "bindata =  {DateTime.now.Instant-$init}";
> 
> 
> Output:
> 
> Bindata= 0.00060054
> 
> So it passed from approx 1.1 to 0.0006 secs. That's quite an improvement!
> 
> Thank you so much.
> 
> Best regards,
> David Santiago
> 
> 
> Ralph Mellor <ralphdjmellor@gmail.com> escreveu no dia quarta,
> 17/06/2020 à(s) 11:57:
>> 
>>> Unfortunately, i get the error "Error X::AdHoc+{X::Await::Died}+{X::React::Died}: Don't know how many
>> elements a C array returned from a library"
>> 
>> I googled the error message and got a bunch of matches including this:
>> 
>> https://stackoverflow.com/questions/51081475/getting-data-out-of-native-pointers
>> 
>> This will show the way to maximize the speed because it minimizes
>> the *number* of copy operations (to one) and expense of the copy
>> (by making it native code).
>> 
>> hth

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About