Skip to content

Perf: Manually parse timezone offset

Kevin Funk requested to merge work/kfunk/perf-remove-qtime-fromstring-usage into master

Manually parse the timezone offset instead of using the way more expensive QTime::fromString. QTime::fromString also checks the current locale which should not be needed in this case here (timezone offset is just an numeric +/- offset, ideally).

Performance gain is roughly around ~7% according to no. of instructions. See benchmarks below.

BENCHMARK BEFORE THIS PATCH:

Performance counter stats for './bin/vcardtool_benchmark' (5 runs):

        579,71 msec task-clock                #    0,999 CPUs utilized            ( +-  0,57% )
            13      context-switches          #   23,115 /sec                     ( +- 17,75% )
             1      cpu-migrations            #    1,380 /sec                     ( +- 46,77% )
           784      page-faults               #    1,353 K/sec                    ( +-  0,23% )
 2.267.190.008      cycles                    #    3,911 GHz                      ( +-  0,80% )
 3.850.940.558      instructions              #    1,70  insn per cycle           ( +-  0,46% )
   661.816.844      branches                  #    1,142 G/sec                    ( +-  0,41% )
     2.673.672      branch-misses             #    0,40% of all branches          ( +-  0,76% )

       0,58042 +- 0,00326 seconds time elapsed  ( +-  0,56% )

BENCHMARK AFTER THIS PATCH:

Performance counter stats for './bin/vcardtool_benchmark' (5 runs):

        547,03 msec task-clock                #    0,998 CPUs utilized            ( +-  1,60% )
            21      context-switches          #   38,024 /sec                     ( +- 48,42% )
             1      cpu-migrations            #    1,097 /sec                     ( +- 66,67% )
           781      page-faults               #    1,428 K/sec                    ( +-  0,16% )
 2.119.015.586      cycles                    #    3,874 GHz                      ( +-  0,47% )
 3.576.505.694      instructions              #    1,69  insn per cycle           ( +-  0,52% )
   611.467.363      branches                  #    1,118 G/sec                    ( +-  0,47% )
     2.428.617      branch-misses             #    0,40% of all branches          ( +-  2,33% )

       0,54804 +- 0,00874 seconds time elapsed  ( +-  1,59% )

Merge request reports