Bugzilla – Attachment 105833 Details for
Bug 25723
Improve efficiency of holiday calculation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25723: [DO NOT PUSH] Benchmark Script
Bug-25723-DO-NOT-PUSH-Benchmark-Script.patch (text/plain), 2.28 KB, created by
Martin Renvoize (ashimema)
on 2020-06-12 15:03:20 UTC
(
hide
)
Description:
Bug 25723: [DO NOT PUSH] Benchmark Script
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2020-06-12 15:03:20 UTC
Size:
2.28 KB
patch
obsolete
>From 54d1c0ca13f1ebdc5eb07e18b76cc99ab80e256e Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 12 Jun 2020 12:40:39 +0100 >Subject: [PATCH] Bug 25723: [DO NOT PUSH] Benchmark Script > >A quick benchmark to compare DateTime::Set->contains to a simple hashref >lookup >--- > misc/devel/benchmark_calendar.pl | 62 ++++++++++++++++++++++++++++++++ > 1 file changed, 62 insertions(+) > create mode 100644 misc/devel/benchmark_calendar.pl > >diff --git a/misc/devel/benchmark_calendar.pl b/misc/devel/benchmark_calendar.pl >new file mode 100644 >index 0000000000..29b8a13630 >--- /dev/null >+++ b/misc/devel/benchmark_calendar.pl >@@ -0,0 +1,62 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Copyright 2016 Koha Development Team >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+use Benchmark; >+ >+use DateTime; >+use DateTime::Set; >+use DateTime::Event::Random; >+ >+my $start = DateTime->new( year => 2020, month => 3 ); >+my $end = DateTime->new( year => 2020, month => 5 ); >+my $set = DateTime::Event::Random->new_cached( >+ days => 5, >+ start => $start, >+ end => $end >+); >+ >+my $exception_holidays = {}; >+my $iter = $set->iterator; >+while ( my $dt = $iter->next ) { >+ $exception_holidays->{ $dt->ymd('') } = 1; >+} >+ >+my $test_datetime = >+ DateTime::Event::Random->datetime( start => $start, end => $end ); >+my $test_datestring = $test_datetime->ymd(''); >+ >+my $time_set = sub { >+ return $set->contains($test_datetime); >+ >+}; >+ >+my $time_hash = sub { >+ return 1 if ( $exception_holidays->{$test_datestring} ); >+ return 0; >+ >+}; >+ >+Benchmark::cmpthese( >+ -10, >+ { >+ 'DateTime::Set' => $time_set, >+ 'hashref' => $time_hash, >+ } >+); >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 25723
:
105789
|
105792
|
105793
|
105830
|
105831
|
105832
|
105833
|
105834
|
105835
|
105836
|
105936
|
105937
|
105939
|
105941
|
105947
|
105954
|
105955
|
105956
|
105957
|
105958
|
105959
|
105960
|
105961
|
105962
|
105963
|
105964
|
105965
|
105966
|
105967
|
105968
|
105969
|
105970
|
106991
|
106992
|
106993
|
106994
|
106995
|
106996
|
106997
|
106998
|
106999
|
107000
|
107001
|
107002
|
107003
|
107004
|
107005
|
107006
|
107007
|
107008
|
107009
|
107010
|
107013
|
107014
|
107015
|
107016
|
107017
|
107018
|
107019
|
107020
|
107021
|
107022
|
107023
|
107025