Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Benchmarktools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Extensions
Benchmarktools
Merge requests
!2
upgrade of civix to 23.02.01
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
upgrade of civix to 23.02.01
1.x-1.1.0
into
1.x
Overview
0
Commits
4
Pipelines
0
Changes
12
Merged
VangelisP
requested to merge
1.x-1.1.0
into
1.x
9 months ago
Overview
0
Commits
4
Pipelines
0
Changes
12
Expand
0
0
Merge request reports
Compare
1.x
version 2
fcb38d79
9 months ago
version 1
808b126b
9 months ago
1.x (base)
and
latest version
latest version
08fa3148
4 commits,
9 months ago
version 2
fcb38d79
2 commits,
9 months ago
version 1
808b126b
1 commit,
9 months ago
12 files
+
384
−
396
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
12
Search (e.g. *.vue) (Ctrl+P)
CRM/Benchmarktools/BAO/API4benchmarks.php
0 → 100644
+
94
−
0
Options
<?php
use
CRM_Benchmarktools_BAO_Benchmarktools
as
B
;
class
CRM_Benchmarktools_BAO_API4benchmarks
{
public
static
function
runTest
(
$count
=
1
,
$action
=
'apiv4_contact_create'
)
{
if
(
$action
==
'apiv4_contact_create'
)
{
$results
=
self
::
createAPIv4Contacts
(
$count
);
return
$results
;
}
elseif
(
$action
==
'apiv4_contact_delete'
)
{
$results
=
self
::
deleteAPIv4Contacts
(
$count
);
return
$results
;
}
}
/**
* createAPIv4Contacts
*
* @param mixed $count
* @return void
*/
public
static
function
createAPIv4Contacts
(
$count
)
{
// Count the statistics
$starttime
=
microtime
(
TRUE
);
// Get the loop for the count
$intCount
=
0
;
while
(
$intCount
<
$count
)
{
// Get some random names
$data
=
B
::
getRandomNames
(
1
);
$names
=
reset
(
$data
);
$names
[
'external_identifier'
]
=
'RND-'
.
rand
(
1111111111
,
9999999999
);
// Create the contact(s)
$results
=
\Civi\Api4\Contact
::
create
(
FALSE
)
->
addValue
(
'first_name'
,
$names
[
'first_name'
])
->
addValue
(
'last_name'
,
$names
[
'last_name'
])
->
addValue
(
'external_identifier'
,
$names
[
'external_identifier'
])
->
addValue
(
'contact_type'
,
'Individual'
)
->
execute
();
$intCount
++
;
}
$stepTime
=
microtime
(
TRUE
);
$execTime
=
number_format
((
float
)
(
$stepTime
-
$starttime
),
3
);
$results
=
[
'process_time'
=>
$execTime
,
'type'
=>
'apiv4_contact_create'
,
'count'
=>
$count
,
];
return
$results
;
}
/**
* deleteAPIv4Contacts
*
* @param mixed $count
* @return void
*/
public
static
function
deleteAPIv4Contacts
(
$count
)
{
$actualCount
=
0
;
// First get a list of contacts, up to the limit of the $count
$contacts
=
\Civi\Api4\Contact
::
get
(
FALSE
)
->
addSelect
(
'id'
)
->
addWhere
(
'external_identifier'
,
'LIKE'
,
'RND-%'
)
->
setLimit
(
$count
)
->
execute
();
// Start the counter
// Count the statistics
$starttime
=
microtime
(
TRUE
);
foreach
(
$contacts
as
$contact
)
{
$results
=
\Civi\Api4\Contact
::
delete
(
FALSE
)
->
addWhere
(
'id'
,
'='
,
$contact
[
'id'
])
->
execute
();
$actualCount
++
;
}
$stepTime
=
microtime
(
TRUE
);
$execTime
=
number_format
((
float
)
(
$stepTime
-
$starttime
),
3
);
$results
=
[
'process_time'
=>
$execTime
,
'type'
=>
'apiv4_contact_delete'
,
'count'
=>
$actualCount
,
];
return
$results
;
}
}
Loading