Reputation: 123
After imports the first line I have is a print, but it takes probably 10 seconds for this line to print. I'm pretty sure use Bio::EnsEMBL::Registry; is the culprit here, as I can take away all the hard coded references and it stil loads slowly (the rest are pretty standard imports.
use strict;
use warnings;
use lib "$ENV{HOME}/Ensembl/src/bioperl-1.6.1";
use lib "$ENV{HOME}/Ensembl/src/ensembl/modules";
use lib "$ENV{HOME}/Ensembl/src/ensembl-compara/modules";
use lib "$ENV{HOME}/Ensembl/src/ensembl-variation/modules";
use lib "$ENV{HOME}/Ensembl/src/ensembl-funcgen/modules";
use Bio::EnsEMBL::Registry;
use Data::Dumper;
use Switch;
use DBI;
#****CONNECT TO ENSEMBL****
print"Establishing connection...";
Is there anything I can do to speed up the time it takes to run this script? Thakns
Upvotes: 0
Views: 378
Reputation: 9305
Check the contents of the environment variable ENSEMBL_REGISTRY
and the file /usr/local/share/ensembl_registry.conf
– they can specify databases to connect to and download the addresses of other databases.
Upvotes: 3
Reputation: 118156
The answer probably depends on what comes after print"Establishing connection...";
If there is a network connection involved, that might explain the lag.
Also, you do not have a newline ("\n"
) at the end of the message, therefore, it may be buffered, and the time it appears on your screen may not correspond to the time it takes to reach the statement.
Therefore, you need to actually time how long it takes for the use Bio::EnsEMBL::Registry;
line to be completed, and how long it takes for the "establishing connection" parts to be completed.
This is where the $^T
variable comes in handy (see perldoc -v '$^T'
):
use strict;
use warnings;
use lib "$ENV{HOME}/Ensembl/src/bioperl-1.6.1";
use lib "$ENV{HOME}/Ensembl/src/ensembl/modules";
use lib "$ENV{HOME}/Ensembl/src/ensembl-compara/modules";
use lib "$ENV{HOME}/Ensembl/src/ensembl-variation/modules";
use lib "$ENV{HOME}/Ensembl/src/ensembl-funcgen/modules";
use Bio::EnsEMBL::Registry;
BEGIN { printf "Loaded 'Bio::EnsEMBL::Registry': [%d] seconds\n", time - $^T };
use Data::Dumper;
use Switch;
use DBI;
#****CONNECT TO ENSEMBL****
printf "Establishing connection ... [%d] seconds\n", time - $^T;
Of course, it may also be useful to switch to a decent logging system.
If it really is the database connection taking a long time, the first thing you should check is if DNS is involved.
Upvotes: 5