Re: [Arsperl-users] Performance problems
Brought to you by:
jeffmurphy
|
From: Thilo S. <thi...@ap...> - 2007-08-02 11:13:12
|
In the "foreach" loop, you are executing a separate API call for every
field. It should be much faster to fetch the whole entry with one call:
%entry = ars_GetEntry( $ctrl, $ARSschema, $entry_id, $x1,..,$xn );
die "ars_GetEntry($ARSschema,$entry_id): $ars_errstr" if $ars_errstr;
print datafile join("|", map {$entry{$_}} ($x1,..,$x)), "\n";
Using ars_GetListEntryWithFields (if you aren't fetching large char
(over 255 character) or diary fields) or ars_GetMultipleEntries might
improve the performance even a bit further.
By the way, instead of having n variables $x1,...,$xn for the field ids,
a better solution would be to store them in an array:
my @names = ($var1,...,$varN);
my @fieldIds;
foreach my $name ( @names ){
push @fieldIds, ars_GetFieldByName( $ctrl, $schema, $name );
}
and then call
%entry = ars_GetEntry( $ctrl, $ARSschema, $entry_id, @fieldIds );
I'd also like to know some more details about what's going wrong with
ars_GetFieldTable. Maybe this is a bug in ARSperl and your informations
could help me to fix it.
Best regards,
Thilo
Paizo wrote:
>
> Hi Listeners,
>
> I have some performance problem executing a perl script working like below:
>
>
>
> $var1 = "something1";
> ($x1 = ars_GetFieldByName($ctrl, $ARSschema, $var1)) || die "bla bla
> bla.\n";
>
> ...
>
> $varn = "somethingn";
> ($xn = ars_GetFieldByName($ctrl, $ARSschema, $var1)) || die "bla bla
> bla.\n";
>
> #####i used ars_GetFieldByName because ars_GetFieldTable didn't work
> always ( i don't know why )
>
> #######then i load the qualifier:
>
> ($qual = ars_LoadQualifier($ctrl, $ARSschema, $str_qual)) ||
> die "ars_LoadQualifier: $ars_errstr";
>
> ...
>
> ####i retrieve the results ( don't take too much time ):
>
> (%entries = ars_GetListEntry($ctrl, $ARSschema, $qual, 0, 0)) || die
> "ars_GetListEntry: $ars_errstr";
>
> #### then i cicle for save the data in a file ( that is the bottle neck ):
>
> foreach $entry_id (sort keys %entries) {
>
> $something1 = ars_GetEntry($ctrl, $ARSschema, $entry_id,$x1);
> ...
> $somethingn = ars_GetEntry($ctrl, $ARSschema, $entry_id,$xn);
>
> print datafile "$something1|$something2|...|$somethingn\n";
>
> }
>
>
> That's take up too 1 hour for finish while using the same qualification
> with AR System User take less than 2 minuts....
>
> How can i speed up that code?
>
> Thanks,
>
> Paizo
>
>
> --
> --------------------
> A me cugin na volta xe ndà dal geataro e el ga domandà na coppetta
> trigusto co i gusti seegheta, sarexe e schie co na fettina de poenta.
> El geataro pena sentio cheà goduriosa scelta, el se ga messo subito el
> pigiama de banane e el ghe ga messo in testa a corona de poegge medie e
> lo ga fatto diventare Re dei Gelati Biricchini.
> -----------------------
> Confezione trigusto seegheta/sarexe/chie co pratico contenitore par e
> fete de poenta, stile estatè o quea dea ciocoeata
> Altri gusti poe essere bigadini/kiwi/lasonil co socoi de vacca da
> tociare o erbagatta/straciatella/calsina co coe de sorxe da tociare
> ------------
> Rileggendo a firma diria che se poe puntare al mercato dei ghiaccioli
> col el gusto crema al diserbo e paraflù ricoperta da una soffice crosta
> de pus co al posto del bacheto un termometro anale pratico pa misurarse
> a freve dopo aver magnà el geato (chi xe che no lo fa al giorno
> d'oggi?!?!). Garantite scorese bitonali e solfeggi anali.
>
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Arsperl-users mailing list
> Ars...@ar...
> https://lists.sourceforge.net/lists/listinfo/arsperl-users
|