in reply to Re^4: "exists $hash{key}" is slower than "$hash{key}"
in thread "exists $hash{key}" is slower than "$hash{key}"

The point of the exercise is not to access lexical variables. They are used only so something happens in case that code will otherwise be optimised away (I don't know the internals well enough to be sure). I should have been clearer about this in my original post.

  • Comment on Re^5: "exists $hash{key}" is slower than "$hash{key}"

Replies are listed 'Best First'.
Re^6: "exists $hash{key}" is slower than "$hash{key}"
by tobyink (Canon) on Jan 07, 2020 at 08:30 UTC

    But %h is a lexical variable too, and the point of the exercise is to access that.

      The point was to assess the relative difference exists $h{$k} vs $h{$k}, not the absolute speed. A few more details are in 11111212.

      Apologies for the confusion and/or lack of clarity.

Re^6: "exists $hash{key}" is slower than "$hash{key}"
by LanX (Saint) on Jan 07, 2020 at 13:37 UTC
    > The point of the exercise is not to access lexical variables.

    But you are measuring them too.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

      Yes, the lexical variables are part of the absolute timings.

      However, it's the relative timings that are of interest in this case as the point of the exercise was to assess the difference between exists $h{$k} or $h{$k}. If all other components are held constant then the timing differences should be due to the use of either of the two idioms (noting that the benchmarks need to be updated given dave_the_m's comments in 341121).