Skip to content

Instantly share code, notes, and snippets.

View gnucifer's full-sized avatar

David Gustafsson gnucifer

  • Gothenburg University Library
  • Gothenburg
View GitHub Profile
#!/usr/bin/perl
use C4::Context;
use Koha::BiblioUtils;
my $records = Koha::BiblioUtils->get_all_biblios_iterator({ batched => 1 });
$limit = 10000;
while ($limit--) {
$records->next();
}
#!/usr/bin/perl
use C4::Context;
use C4::Biblio;
use C4::Items;
use t::lib::Mocks;
use Time::HiRes qw(gettimeofday tv_interval);
use List::MoreUtils qw(natatime);
t::lib::Mocks::mock_preference('item-level_itypes', '1');
my $itemnumbers = C4::Context->dbh->selectcol_arrayref(qq{SELECT itemnumber FROM items LIMIT 2000});
#!/usr/bin/perl
use C4::Context;
use C4::Biblio;
use C4::Items;
use t::lib::Mocks;
use Time::HiRes qw(gettimeofday tv_interval);
t::lib::Mocks::mock_preference('item-level_itypes', '1');
my $itemnumbers = C4::Context->dbh->selectcol_arrayref(qq{SELECT itemnumber FROM items WHERE biblionumber = 2});
sub GetItems {
my ($itemnumbers, $barcodes, $serial) = @_;
my $dbh = C4::Context->dbh;
my $items_data = [];
# Important: If 'item-level_itypes' preference is not set Koha::Item::effective_itemtype()
# will be equal to $item->{itype} and it is possible to fetch the data directly from items table.
# This will have a much smaller footprint then unblessing the item objects fetched through
# find/search. If more calculated attributes are added in the future, this code will need
# to account for that.
#!/usr/bin/perl
use C4::Context;
use C4::Biblio;
use C4::Items;
use t::lib::Mocks;
use Time::HiRes qw(gettimeofday tv_interval);
t::lib::Mocks::mock_preference('item-level_itypes', '1');
my $result = C4::Context->dbh->selectcol_arrayref(qq{SELECT itemnumber FROM items LIMIT 1});
#!/usr/bin/perl
use C4::Context;
use C4::Biblio;
use t::lib::Mocks;
my $biblionumber = <biblionumber_with_items_goes_here>;
# Warm up caches to get a more fair benchmark
GetMarcBiblio({biblionumber => $biblionumber, embed_items => 1});
DB::enable_profile();
#!/usr/bin/perl
use C4::Biblio;
$i = 50000;
while($i--) {
C4::Biblio::GetMarcSubfieldStructure('', {unsafe => 1});
}
#!/usr/bin/perl
use C4::Context;
use C4::Biblio;
my $biblio_ids = C4::Context->dbh->selectcol_arrayref(qq{SELECT biblionumber FROM biblio LIMIT 5000});
foreach my $id (@{$biblio_ids}) {
GetMarcBiblio({biblionumber => $id, embed_items => 1});
}
#!/usr/bin/perl
use C4::Context;
my $i = 200000;
while($i--) {
C4::Context->dbh->selectcol_arrayref(qq{SELECT biblionumber FROM biblio LIMIT 1});
}