in reply to where does the time go?

That's a little hard to reproduce. But if you can change this code to show the same behaviour then we may be able to help a little more.

use warnings; use strict; use Devel::Timer; search (); sub search { my $class = shift; my $t = Devel::Timer->new; $t->mark('a'); validate_search_index (); $t->mark('b'); my $target = 'some text to search some text to search some text to + search some text to search '; $target =~ /y/ for (0..10000); $t->mark('c'); $target =~ /y/ for (0..10000); $t->mark('d'); $target =~ /y/ for (0..10000); $t->report; } sub validate_search_index { my $t = Devel::Timer->new; $t->mark(0); my $target = 'some text to search some text to search some text to + search some text to search '; $target =~ /y/ for (0..10000); $t->mark(1); $target =~ /y/ for (0..10000); $t->mark(2); $target =~ /y/ for (0..10000); $t->mark(3); $target =~ /y/ for (0..10000); $t->mark(4); $target =~ /y/ for (0..10000); $t->report; }

Reports:

Devel::Timer Report -- Total time: 0.0153 secs Interval Time Percent ---------------------------------------------- 03 -> 04 0.0045 29.47% 2 -> 3 04 -> 05 0.0036 23.84% 3 -> 4 01 -> 02 0.0036 23.59% 0 -> 1 02 -> 03 0.0035 22.95% 1 -> 2 00 -> 01 0.0000 0.14% INIT -> 0 Devel::Timer Report -- Total time: 0.0268 secs Interval Time Percent ---------------------------------------------- 01 -> 02 0.0195 72.63% a -> b 02 -> 03 0.0037 13.87% b -> c 03 -> 04 0.0036 13.37% c -> d 00 -> 01 0.0000 0.14% INIT -> a

Perl is Huffman encoded by design.

Replies are listed 'Best First'.
Re^2: where does the time go?
by badaiaqrandista (Pilgrim) on Nov 01, 2005 at 00:50 UTC

    I am having a hard time to simplify the actual code because it calls other classes and creates SQL queries. What do you suggest me to do? Should I just post the original code? But it won't be runnable.

    Thanks

      Try to retain the same structure, but replace SQL and such non-portable stuff with some sort of time wasting code (like the regexs that I used) to use similar amounts of time.

      My guess is that the structure is important in some fashion (a hole in the timing perhaps), but that the details of how the time is used should not be important.


      Perl is Huffman encoded by design.