Re: [Arsperl-users] Performance problems
Brought to you by:
jeffmurphy
|
From: Clayton S. <cla...@gm...> - 2007-08-02 11:44:10
|
Paizo wrote:
> Hi Listeners,
>
> I have some performance problem executing a perl script working like below:
>
> [ code snipped ]
> 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,
One way to get an excellent increase in speed is to fetch all of the
fields for each entry at once instead of individually.
You should work hard to reduce the number of ars_ calls required
because they involve the slowest part of this set up: the network.
I'll show you a modified version of your final loop that does this.
But first put your field id fetching into a loop and your field ids
into an array so that they are easier to add/remove fields and pass
the field ids on to the ars_GetEntry call.
# Getting Field Ids
my @field_names = ('something1', ... ,'somthingn');
my @field_ids;
foreach my $field_name ( @field_names ){
my $field_id;
($field_id = ars_GetFieldByName($ctrl, $ARSschema, $field_name) ||
die "bla bla bla.\n";
push @field_ids, $field_id;
}
# Getting Entries
foreach my $entry_id (sort keys %entries) {
my %entry = ars_GetEntry($ctrl, $ARSschema, $entry_id, @field_ids);
print datafile join("|", @entry{@field_ids} ) . "\n";
}
I hope this helps,
--
Clayton Scott
cla...@gm...
|