This module contains procedures and generic interfaces for finding locations of a pattern in arrays of various types at the specified instances of occurrence of pattern.
More...
This module contains procedures and generic interfaces for finding locations of a pattern in arrays of various types at the specified instances of occurrence of pattern.
- Benchmarks:
Benchmark :: The runtime performance of setLoc for scalar vs. vector input pattern
argument. ⛓
4 use iso_fortran_env,
only:
error_unit
13 integer(IK) :: fileUnit
14 integer(IK) ,
parameter :: NSIZE
= 18_IK
15 integer(IK) ,
parameter :: NBENCH
= 2_IK
16 integer(IK) :: arraySize(NSIZE)
17 logical(LK) :: dummy
= .true._LK
18 integer(IK) ,
allocatable :: loc(:)
19 integer(IK) ,
allocatable :: array(:)
20 integer(IK) ,
parameter :: pattern(
1)
= 0_IK
21 type(bench_type) :: bench(NBENCH)
23 bench(
1)
= bench_type(name
= SK_
"scalarPattern", exec
= scalarPattern , overhead
= setOverhead)
24 bench(
2)
= bench_type(name
= SK_
"vectorPattern", exec
= vectorPattern , overhead
= setOverhead)
26 arraySize
= [(
2_IK**isize, isize
= 1_IK, NSIZE )]
27 loc
= [
integer(IK) ::]
30 write(
*,
"(*(g0,:,' '))")
31 write(
*,
"(*(g0,:,' '))")
"scalarPattern() vs. vectorPattern()"
32 write(
*,
"(*(g0,:,' '))")
34 open(newunit
= fileUnit, file
= "main.out", status
= "replace")
36 write(fileUnit,
"(*(g0,:,','))")
"arraySize", (bench(i)
%name, i
= 1, NBENCH)
38 loopOverArraySize:
do isize
= 1, NSIZE
40 write(
*,
"(*(g0,:,' '))")
"Benchmarking with size", arraySize(isize)
41 allocate(array(arraySize(isize)))
44 bench(i)
%timing
= bench(i)
%getTiming(minsec
= 0.05_RK)
48 write(fileUnit,
"(*(g0,:,','))") arraySize(isize), (bench(i)
%timing
%mean, i
= 1, NBENCH)
50 end do loopOverArraySize
51 write(
*,
"(*(g0,:,' '))") dummy
52 write(
*,
"(*(g0,:,' '))")
62 subroutine setOverhead()
67 subroutine initialize()
72 dummy
= dummy
.and. size(loc,
1,
IK)
== nloc
75 subroutine scalarPattern()
78 call setLoc(loc, nloc, array, pattern(
1),
1_IK)
82 subroutine vectorPattern()
86 call setLoc(loc, nloc, array, pattern,
1_IK)
Return an allocatable array containing the indices of the locations within the input array where the ...
Generate and return an object of type timing_type containing the benchmark timing information and sta...
This module contains procedures and generic interfaces for finding locations of a pattern in arrays o...
This module contains abstract interfaces and types that facilitate benchmarking of different procedur...
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
integer, parameter RK
The default real kind in the ParaMonte library: real64 in Fortran, c_double in C-Fortran Interoperati...
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
This is the class for creating benchmark and performance-profiling objects.
Example Unix compile command via Intel ifort
compiler ⛓
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Example Windows Batch compile command via Intel ifort
compiler ⛓
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
Example Unix / MinGW compile command via GNU gfortran
compiler ⛓
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Postprocessing of the benchmark output ⛓
3import matplotlib.pyplot
as plt
9methods = [
"scalarPattern",
"vectorPattern"]
11df = pd.read_csv(
"main.out")
17ax = plt.figure(figsize = 1.25 * np.array([6.4,4.6]), dpi = 200)
21 plt.plot( df[
"arraySize"].values
26plt.xticks(fontsize = fontsize)
27plt.yticks(fontsize = fontsize)
28ax.set_xlabel(
"Array Size", fontsize = fontsize)
29ax.set_ylabel(
"Runtime [ seconds ]", fontsize = fontsize)
30ax.set_title(
"Finding array segments with pattern(1) (scalar) vs. pattern(1:1) (vector).\nLower is better.", fontsize = fontsize)
34plt.grid(visible =
True, which =
"both", axis =
"both", color =
"0.85", linestyle =
"-")
35ax.tick_params(axis =
"y", which =
"minor")
36ax.tick_params(axis =
"x", which =
"minor")
44plt.savefig(
"benchmark.setLoc-scalarPattern_vs_vectorPattern.runtime.png")
50ax = plt.figure(figsize = 1.25 * np.array([6.4,4.6]), dpi = 200)
53plt.plot( df[
"arraySize"].values
54 , np.ones(len(df[
"arraySize"].values))
59plt.plot( df[
"arraySize"].values
60 , df[
"vectorPattern"].values / df[
"scalarPattern"].values
64plt.xticks(fontsize = fontsize)
65plt.yticks(fontsize = fontsize)
66ax.set_xlabel(
"Array Size", fontsize = fontsize)
67ax.set_ylabel(
"Runtime compared to scalarPattern()", fontsize = fontsize)
68ax.set_title(
"Runtime Ratio: Find pattern(1:1) / Find pattern(1).\nLower means faster. Lower than 1 means faster than scalarPattern.", fontsize = fontsize)
72plt.grid(visible =
True, which =
"both", axis =
"both", color =
"0.85", linestyle =
"-")
73ax.tick_params(axis =
"y", which =
"minor")
74ax.tick_params(axis =
"x", which =
"minor")
75ax.legend ( [
"scalarPattern",
"vectorPattern"]
82plt.savefig(
"benchmark.setLoc-scalarPattern_vs_vectorPattern.runtime.ratio.png")
Visualization of the benchmark output ⛓
Benchmark moral ⛓
- The procedures under the generic interface setLoc take both scalar and vector
pattern
arguments.
As evidenced by the above benchmark, when the input pattern
is vector of length 1
, it is much faster, possibly up to 4X, to pass pattern
as a scalar instead of a whole array of length 1
.
Note that this benchmark is likely irrelevant to finding substrings in Fortran strings.
Benchmark :: The runtime performance of getLoc vs. setLoc ⛓
4 use iso_fortran_env,
only:
error_unit
13 integer(IK) :: fileUnit
14 integer(IK) ,
parameter :: blindness
= 1
15 integer(IK) ,
parameter :: NSIZE
= 18_IK
16 integer(IK) ,
parameter :: NBENCH
= 2_IK
17 integer(IK) :: arraySize(NSIZE)
18 logical(LK) :: dummy
= .true._LK
19 integer(IK) ,
allocatable :: loc(:)
20 character(:, SK),
allocatable :: array
21 character(
1,SK) :: pattern
22 type(bench_type) :: bench(NBENCH)
24 bench(
1)
= bench_type(name
= SK_
"setLoc", exec
= setLoc , overhead
= setOverhead)
25 bench(
2)
= bench_type(name
= SK_
"getLoc", exec
= getLoc , overhead
= setOverhead)
27 arraySize
= [(
2_IK**isize, isize
= 1_IK, NSIZE )]
28 loc
= [
integer(IK) ::]
31 write(
*,
"(*(g0,:,' '))")
32 write(
*,
"(*(g0,:,' '))")
"setLoc() vs. getLoc()"
33 write(
*,
"(*(g0,:,' '))")
35 open(newunit
= fileUnit, file
= "main.out", status
= "replace")
37 write(fileUnit,
"(*(g0,:,','))")
"arraySize", (bench(i)
%name, i
= 1, NBENCH)
39 loopOverArraySize:
do isize
= 1, NSIZE
41 write(
*,
"(*(g0,:,' '))")
"Benchmarking with size", arraySize(isize)
43 allocate(
character(arraySize(isize)) :: array)
45 bench(i)
%timing
= bench(i)
%getTiming(minsec
= 0.05_RK)
49 write(fileUnit,
"(*(g0,:,','))") arraySize(isize), (bench(i)
%timing
%mean, i
= 1, NBENCH)
51 end do loopOverArraySize
52 write(
*,
"(*(g0,:,' '))") dummy
53 write(
*,
"(*(g0,:,' '))")
63 subroutine setOverhead()
68 subroutine initialize()
72 array(:)
= repeat(pattern,
len(array))
76 dummy
= dummy
.and. size(loc,
1,
IK)
== nloc
84 call setLoc(loc, nloc, array, pattern, blindness)
93 loc
= getLoc(array, pattern)
Generate and return an allocatable array containing the indices of the locations within the input arr...
Return a uniform random scalar or contiguous array of arbitrary rank of randomly uniformly distribute...
This module contains classes and procedures for computing various statistical quantities related to t...
Example Unix compile command via Intel ifort
compiler ⛓
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Example Windows Batch compile command via Intel ifort
compiler ⛓
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
Example Unix / MinGW compile command via GNU gfortran
compiler ⛓
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Postprocessing of the benchmark output ⛓
3import matplotlib.pyplot
as plt
9methods = [
"setLoc",
"getLoc"]
11df = pd.read_csv(
"main.out")
17ax = plt.figure(figsize = 1.25 * np.array([6.4,4.6]), dpi = 200)
21 plt.plot( df[
"arraySize"].values
26plt.xticks(fontsize = fontsize)
27plt.yticks(fontsize = fontsize)
28ax.set_xlabel(
"Array Size", fontsize = fontsize)
29ax.set_ylabel(
"Runtime [ seconds ]", fontsize = fontsize)
30ax.set_title(
"setLoc() vs. getLoc()\nLower is better.", fontsize = fontsize)
34plt.grid(visible =
True, which =
"both", axis =
"both", color =
"0.85", linestyle =
"-")
35ax.tick_params(axis =
"y", which =
"minor")
36ax.tick_params(axis =
"x", which =
"minor")
44plt.savefig(
"benchmark.getLoc_vs_setLoc.runtime.png")
50ax = plt.figure(figsize = 1.25 * np.array([6.4,4.6]), dpi = 200)
53plt.plot( df[
"arraySize"].values
54 , np.ones(len(df[
"arraySize"].values))
59plt.plot( df[
"arraySize"].values
60 , df[
"getLoc"].values / df[
"setLoc"].values
64plt.xticks(fontsize = fontsize)
65plt.yticks(fontsize = fontsize)
66ax.set_xlabel(
"Array Size", fontsize = fontsize)
67ax.set_ylabel(
"Runtime compared to setLoc()", fontsize = fontsize)
68ax.set_title(
"getLoc() / setLoc()\nLower means faster. Lower than 1 means faster than setLoc().", fontsize = fontsize)
72plt.grid(visible =
True, which =
"both", axis =
"both", color =
"0.85", linestyle =
"-")
73ax.tick_params(axis =
"y", which =
"minor")
74ax.tick_params(axis =
"x", which =
"minor")
75ax.legend ( [
"setLoc",
"getLoc"]
82plt.savefig(
"benchmark.getLoc_vs_setLoc.runtime.ratio.png")
Visualization of the benchmark output ⛓
Benchmark moral ⛓
- The procedures under the generic interface getLoc are functions while the procedures under the generic interface setLoc are subroutines.
From the benchmark results, it appears that the functional interface performs slightly less efficiently than the subroutine interface when the input array
size is small.
Nevertheless, the difference appears to be marginal and insignificant in most practical situations.
- Note that this benchmark considers the worst-case scenario where all elements of the input
array
match the input pattern
and must be therefore indexed.
Benchmark :: The runtime performance of setLoc with and without sorted = .true.
and positive = .true.
optional input arguments. ⛓
4 use iso_fortran_env,
only:
error_unit
14 integer(IK) :: fileUnit
15 integer(IK) ,
parameter :: NSIZE
= 20_IK
16 integer(IK) ,
parameter :: NBENCH
= 2_IK
17 integer(IK) :: arraySize(NSIZE)
18 logical(LK) :: dummy
= .true._LK
19 integer(IK) ,
allocatable :: instance(:)
20 integer(IK) ,
allocatable :: loc(:)
21 integer(IK) ,
allocatable :: array(:)
22 integer(IK) :: pattern
23 type(bench_type) :: bench(NBENCH)
26 bench(
1)
= bench_type(name
= SK_
"sortedPositive", exec
= sortedPositive , overhead
= setOverhead)
27 bench(
2)
= bench_type(name
= SK_
"defaultOptions", exec
= defaultOptions , overhead
= setOverhead)
29 arraySize
= [(
2_IK**isize, isize
= 1_IK, NSIZE )]
30 loc
= [
integer(IK) ::]
33 write(
*,
"(*(g0,:,' '))")
34 write(
*,
"(*(g0,:,' '))")
"sortedPositive() vs. defaultOptions()"
35 write(
*,
"(*(g0,:,' '))")
37 open(newunit
= fileUnit, file
= "main.out", status
= "replace")
39 write(fileUnit,
"(*(g0,:,','))")
"arraySize", (bench(i)
%name, i
= 1_IK, NBENCH)
41 loopOverArraySize:
do isize
= 1_IK, NSIZE
43 write(
*,
"(*(g0,:,' '))")
"Benchmarking with size", arraySize(isize)
44 instance
= getRange(
1_IK, arraySize(isize))
45 allocate(array(arraySize(isize)))
48 bench(i)
%timing
= bench(i)
%getTiming(minsec
= 0.05_RK)
51 deallocate(array, instance)
52 write(fileUnit,
"(*(g0,:,','))") arraySize(isize), (bench(i)
%timing
%mean, i
= 1_IK, NBENCH)
54 end do loopOverArraySize
55 write(
*,
"(*(g0,:,' '))") dummy
56 write(
*,
"(*(g0,:,' '))")
66 subroutine setOverhead()
71 subroutine initialize()
72 call random_number(unifrnd)
73 pattern
= nint(unifrnd,
kind = IK)
74 array(:)
= pattern
+ 1_IK
78 dummy
= dummy
.and. size(loc,
kind = IK)
== nloc
81 subroutine sortedPositive()
84 call setLoc(loc, nloc, array, pattern, instance,
.true._LK,
.true._LK,
1_IK)
88 subroutine defaultOptions()
92 call setLoc(loc, nloc, array, pattern, instance,
.false._LK,
.false._LK,
1_IK)
Generate minimally-spaced character, integer, real sequences or sequences at fixed intervals of size ...
This module contains procedures and generic interfaces for generating ranges of discrete character,...
Example Unix compile command via Intel ifort
compiler ⛓
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Example Windows Batch compile command via Intel ifort
compiler ⛓
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
Example Unix / MinGW compile command via GNU gfortran
compiler ⛓
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Postprocessing of the benchmark output ⛓
3import matplotlib.pyplot
as plt
9methods = [
"sortedPositive",
"defaultOptions"]
11df = pd.read_csv(
"main.out")
17ax = plt.figure(figsize = 1.25 * np.array([6.4,4.6]), dpi = 200)
21 plt.plot( df[
"arraySize"].values
26plt.xticks(fontsize = fontsize)
27plt.yticks(fontsize = fontsize)
28ax.set_xlabel(
"Array Size", fontsize = fontsize)
29ax.set_ylabel(
"Runtime [ seconds ]", fontsize = fontsize)
30ax.set_title(
"Finding pattern with `sorted = .true._LK, positive = .true.` vs. the default.\nLower is better.", fontsize = fontsize)
34plt.grid(visible =
True, which =
"both", axis =
"both", color =
"0.85", linestyle =
"-")
35ax.tick_params(axis =
"y", which =
"minor")
36ax.tick_params(axis =
"x", which =
"minor")
44plt.savefig(
"benchmark.setLoc-sortedPositive_vs_defaultOptions.runtime.png")
50ax = plt.figure(figsize = 1.25 * np.array([6.4,4.6]), dpi = 200)
53plt.plot( df[
"arraySize"].values
54 , np.ones(len(df[
"arraySize"].values))
59plt.plot( df[
"arraySize"].values
60 , df[
"defaultOptions"].values / df[
"sortedPositive"].values
64plt.xticks(fontsize = fontsize)
65plt.yticks(fontsize = fontsize)
66ax.set_xlabel(
"Array Size", fontsize = fontsize)
67ax.set_ylabel(
"Runtime compared to sortedPositive", fontsize = fontsize)
68ax.set_title(
"Runtime Ratio: Find with sortedPositive / Find with defaultOptions.\nLower means faster. Lower than 1 means faster than finding with sortedPositive.", fontsize = fontsize)
72plt.grid(visible =
True, which =
"both", axis =
"both", color =
"0.85", linestyle =
"-")
73ax.tick_params(axis =
"y", which =
"minor")
74ax.tick_params(axis =
"x", which =
"minor")
75ax.legend ( [
"sortedPositive",
"defaultOptions"]
82plt.savefig(
"benchmark.setLoc-sortedPositive_vs_defaultOptions.runtime.ratio.png")
Visualization of the benchmark output ⛓
Benchmark moral ⛓
- The procedures under the generic interface setLoc take two optional
sorted
and positive
input arguments when the input array of instances instance
is also specified. Setting sorted = .true._LK, positive = .true.
guarantees to the procedures that all elements of instance
are sorted in ascending-order and that no negative or zero value is present in instance
. Hence, the maximum value in instance
corresponds to instance(size(instance))
, saving the procedures the time to find the maximum value of the input instance
.
- As evidenced by the above benchmark, when
sorted = .true._LK, positive = .true.
can be guaranteed by the user, the runtime performance of the procedures could possibly increase 2-3 times compared to when the default values have to be assumed, corresponding to the worst case scenario (sorted = .false._LK, positive = .false.
).
- The results of this benchmark equally hold for the functions under the generic interface getLoc.
Benchmark :: The runtime performance of setLoc with and without iseq
external optional input argument. ⛓
4 use iso_fortran_env,
only:
error_unit
14 integer(IK) :: fileUnit
15 integer(IK) ,
parameter :: blindness
= 1
16 integer(IK) ,
parameter :: NSIZE
= 20_IK
17 integer(IK) ,
parameter :: NBENCH
= 2_IK
18 integer(IK) :: arraySize(NSIZE)
19 logical(LK) :: dummy
= .true._LK
20 integer(IK) ,
allocatable :: instance(:)
21 integer(IK) ,
allocatable :: loc(:)
22 integer(IK) ,
allocatable :: array(:)
23 integer(IK) :: pattern
24 type(bench_type) :: bench(NBENCH)
25 real(RK) :: unifrnd, MeanTime(
2)
= 0._RK
27 bench(
1)
= bench_type(name
= SK_
"default", exec
= default , overhead
= setOverhead)
28 bench(
2)
= bench_type(name
= SK_
"iseqArg", exec
= iseqArg , overhead
= setOverhead)
30 arraySize
= [(
2_IK**isize, isize
= 1_IK, NSIZE )]
31 loc
= [
integer(IK) ::]
34 write(
*,
"(*(g0,:,' '))")
35 write(
*,
"(*(g0,:,' '))")
"iseqArg vs. default"
36 write(
*,
"(*(g0,:,' '))")
38 open(newunit
= fileUnit, file
= "main.out", status
= "replace")
40 write(fileUnit,
"(*(g0,:,','))")
"arraySize", (bench(i)
%name, i
= 1_IK, NBENCH)
42 loopOverArraySize:
do isize
= 1_IK, NSIZE
44 write(
*,
"(*(g0,:,' '))")
"Benchmarking with size", arraySize(isize)
45 instance
= getRange(
1_IK, arraySize(isize))
46 allocate(array(arraySize(isize)))
49 bench(i)
%timing
= bench(i)
%getTiming(minsec
= 0.03_RK)
50 MeanTime(i)
= MeanTime(i)
+ bench(i)
%timing
%mean
53 do i
= NBENCH,
1_IK,
-1_IK
54 bench(i)
%timing
= bench(i)
%getTiming(minsec
= 0.03_RK)
55 MeanTime(i)
= MeanTime(i)
+ bench(i)
%timing
%mean
58 deallocate(array, instance)
59 write(fileUnit,
"(*(g0,:,','))") arraySize(isize), MeanTime
/ 2_IK
61 end do loopOverArraySize
62 write(
*,
"(*(g0,:,' '))") dummy
63 write(
*,
"(*(g0,:,' '))")
73 subroutine setOverhead()
78 subroutine initialize()
79 call random_number(unifrnd)
80 pattern
= nint(unifrnd,
kind = IK)
81 array(:)
= pattern
+ 1_IK
85 dummy
= dummy
.and. size(loc,
1,
IK)
== nloc
91 call setLoc(loc, nloc, array, pattern, iseq,
1_IK)
99 call setLoc(loc, nloc, array, pattern,
1_IK)
104 pure function iseq(arraysegment, pattern)
result(equivalent)
106 integer(IK) ,
intent(in) :: pattern, arraySegment
107 logical(LK) :: equivalent
108 equivalent
= arraySegment
== pattern
Example Unix compile command via Intel ifort
compiler ⛓
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Example Windows Batch compile command via Intel ifort
compiler ⛓
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
Example Unix / MinGW compile command via GNU gfortran
compiler ⛓
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Postprocessing of the benchmark output ⛓
3import matplotlib.pyplot
as plt
9methods = [
"default",
"iseqArg"]
11df = pd.read_csv(
"main.out")
17ax = plt.figure(figsize = 1.25 * np.array([6.4,4.6]), dpi = 200)
21 plt.plot( df[
"arraySize"].values
26plt.xticks(fontsize = fontsize)
27plt.yticks(fontsize = fontsize)
28ax.set_xlabel(
"Array Size", fontsize = fontsize)
29ax.set_ylabel(
"Runtime [ seconds ]", fontsize = fontsize)
30ax.set_title(
"Finding pattern with external `iseq()` vs. default comparison.\nLower is better.", fontsize = fontsize)
34plt.grid(visible =
True, which =
"both", axis =
"both", color =
"0.85", linestyle =
"-")
35ax.tick_params(axis =
"y", which =
"minor")
36ax.tick_params(axis =
"x", which =
"minor")
44plt.savefig(
"benchmark.setLoc-iseqArg_vs_default.runtime.png")
50ax = plt.figure(figsize = 1.25 * np.array([6.4,4.6]), dpi = 200)
53plt.plot( df[
"arraySize"].values
54 , np.ones(len(df[
"arraySize"].values))
59plt.plot( df[
"arraySize"].values
60 , df[
"iseqArg"].values / df[
"default"].values
64plt.xticks(fontsize = fontsize)
65plt.yticks(fontsize = fontsize)
66ax.set_xlabel(
"Array Size", fontsize = fontsize)
67ax.set_ylabel(
"Runtime compared to iseqArg", fontsize = fontsize)
68ax.set_title(
"Runtime Ratio: Comparison with `iseq()` / default.\nLower means faster. Lower than 1 means faster than finding with `iseq()`.", fontsize = fontsize)
72plt.grid(visible =
True, which =
"both", axis =
"both", color =
"0.85", linestyle =
"-")
73ax.tick_params(axis =
"y", which =
"minor")
74ax.tick_params(axis =
"x", which =
"minor")
82plt.savefig(
"benchmark.setLoc-iseqArg_vs_default.runtime.ratio.png")
Visualization of the benchmark output ⛓
Benchmark moral ⛓
- The procedures under the generic interface setLoc take an optional
iseq()
external-function input argument which can perform custom user-defined equivalence checks between the input pattern
and array
segments. By default, the equivalence check is equality (or equivalence for logical
values).
- The presence of an external
iseq
argument does appear to deteriorate the runtime performance of setLoc.
However, the exact amount of this penalty appears to significantly depend on the computing platform and the ability of the compiler to inline the external function.
- The results of this benchmark equally hold for the functions under the generic interface getLoc.
- Test:
- test_pm_arrayFind
Final Remarks ⛓
If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.
-
If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
-
If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.
This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.
- Copyright
- Computational Data Science Lab
- Author:
- Fatemeh Bagheri, Wednesday 12:20 AM, October 13, 2021, Dallas, TX