Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save rnwood/a064cb8656958bb8c84259382f966d08 to your computer and use it in GitHub Desktop.

Select an option

Save rnwood/a064cb8656958bb8c84259382f966d08 to your computer and use it in GitHub Desktop.
$ErrorActionPreference="Stop"
$records = Get-Content -encoding UTF8 "contacts.json" `
| ConvertFrom-Json
[Microsoft.PowerPlatform.Dataverse.Client.ServiceClient]::MaxConnectionTimeout = [TimeSpan]::FromMinutes(10)
foreach($parallelism in 1,2,4,8,16,32,64,128) {
foreach($batchsize in 1000,500,250,100,50,25,10,1) {
$recordcount = $parallelism * $batchsize
$duration = (Measure-Command {
$records `
| Select-Object -First $recordcount `
| Get-Chunk -size ($recordcount/$parallelism) `
| ForEach-Object -ThrottleLimit $parallelism -parallel {
$localconnection = ($using:connection).Clone()
$_ `
| ForEach-Object {
[PSCustomObject]@{
firstname = $_.FirstName;
lastname = $_.LatName;
emailaddress1 = $_.Email;
telephone1 = $_.PhoneNumber
}
} `
| Set-DataverseRecord -Connection $localconnection -TableName contact -BatchSize $using:batchsize -CreateOnly -verbose
}
})
$rps = $recordcount / $duration.TotalSeconds
write-host "$parallelism,$batchsize,$recordcount,$($duration.TotalSeconds),$rps"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment