in reply to Re^6: Speed Improvement
in thread Speed Improvement

No, I'm running 5.20.1, at least on my pc. I took out the use 5.010 and the results are pretty much the same -- something is happening, but nothing good. Yes, study takes the time to build a table to make searching more efficient, something akin to a database index. If the strings are short, or there are only a very few searches to perform, study isn't worth the effort. I should really try it on a sample problem like the one suggested in the docs.

1 Peter 4:10

Replies are listed 'Best First'.
Re^8: Speed Improvement
by dave_the_m (Monsignor) on Dec 02, 2014 at 16:50 UTC
    No, the study keyword does absolutely nothing except return an appropriate boolean for backwards compatibilty. In particular, it is not building up any tables. Here is the C source code for pp_study() in 5.18.0:
    PP(pp_study) { dVAR; dSP; dPOPss; STRLEN len; (void)SvPV(sv, len); if (len == 0 || len > I32_MAX || !SvPOK(sv) || SvUTF8(sv) || SvVAL +ID(sv)) { /* Historically, study was skipped in these cases. */ RETPUSHNO; } /* Make study a no-op. It's no longer useful and its existence complicates matters elsewhere. */ RETPUSHYES; }

    Dave.

Re^8: Speed Improvement
by BrowserUk (Patriarch) on Dec 02, 2014 at 16:47 UTC
    something is happening,

    I'm guessing the differences you are seeing is just down to the overhead of calling into C, doing (almost) nothing, and returning again.

    From pp.c/5.18

    /* Pattern matching */ PP(pp_study) { dVAR; dSP; dPOPss; STRLEN len; (void)SvPV(sv, len); if (len == 0 || len > I32_MAX || !SvPOK(sv) || SvUTF8(sv) || SvVAL +ID(sv)) { /* Historically, study was skipped in these cases. */ RETPUSHNO; } /* Make study a no-op. It's no longer useful and its existence complicates matters elsewhere. */ RETPUSHYES; }

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.