code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def total_memory_kb(self): """Gets the amount of memory on the VM. Returns: The number of kilobytes of memory on the VM. """ if not self._total_memory_kb: self._total_memory_kb = self._GetTotalMemoryKb() return self._total_memory_kb
Gets the amount of memory on the VM. Returns: The number of kilobytes of memory on the VM.
total_memory_kb
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/os_mixin.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/os_mixin.py
Apache-2.0
def IsReachable(self, target_vm): """Indicates whether the target VM can be reached from its internal ip. Args: target_vm: The VM whose reachability is being tested. Returns: True if the internal ip address of the target VM can be reached, false otherwise. """ if target_vm not in...
Indicates whether the target VM can be reached from its internal ip. Args: target_vm: The VM whose reachability is being tested. Returns: True if the internal ip address of the target VM can be reached, false otherwise.
IsReachable
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/os_mixin.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/os_mixin.py
Apache-2.0
def CheckPreprovisionedData( self, install_path, module_name, filename, expected_sha256 ): """Checks preprovisioned data for a checksum. Checks the expected 256sum against the actual sha256sum. Called after the file is downloaded. This function should be overridden by each OS-specific MixIn. ...
Checks preprovisioned data for a checksum. Checks the expected 256sum against the actual sha256sum. Called after the file is downloaded. This function should be overridden by each OS-specific MixIn. Args: install_path: The install path on this VM. The benchmark is installed at this path...
CheckPreprovisionedData
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/os_mixin.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/os_mixin.py
Apache-2.0
def TestConnectRemoteAccessPort(self, port=None, socket_timeout=0.5): """Tries to connect to remote access port and throw if it fails. Args: port: Integer of the port to connect to. Defaults to the default remote connection port of the VM. socket_timeout: The number of seconds to wait on th...
Tries to connect to remote access port and throw if it fails. Args: port: Integer of the port to connect to. Defaults to the default remote connection port of the VM. socket_timeout: The number of seconds to wait on the socket before failing and retrying. If this is too low, the connect...
TestConnectRemoteAccessPort
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/os_mixin.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/os_mixin.py
Apache-2.0
def IsSmtEnabled(self): """Whether simultaneous multithreading (SMT) is enabled on the vm.""" if self._is_smt_enabled is None: self._is_smt_enabled = self._IsSmtEnabled() return self._is_smt_enabled
Whether simultaneous multithreading (SMT) is enabled on the vm.
IsSmtEnabled
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/os_mixin.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/os_mixin.py
Apache-2.0
def SetPackageModuleFunction(function): """Sets the function called by PackageModule; See benchmark_sets.py.""" global _global_package_module_function _global_package_module_function = function
Sets the function called by PackageModule; See benchmark_sets.py.
SetPackageModuleFunction
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/package_lookup.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/package_lookup.py
Apache-2.0
def PackageModule(package_name): """Finds the module for a benchmark by name. Args: package_name: The name of the package. Returns: The package's module, or None if the package is invalid. """ if not _global_package_module_function: raise errors.Setup.InvalidSetupError( 'Cannot call pack...
Finds the module for a benchmark by name. Args: package_name: The name of the package. Returns: The package's module, or None if the package is invalid.
PackageModule
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/package_lookup.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/package_lookup.py
Apache-2.0
def ParseSkipTeardownConditions( skip_teardown_conditions: Collection[str], ) -> Mapping[str, Mapping[str, float | None]]: """Parses the skip_teardown_conditions flag. Used by the validator below and flag_util.ShouldTeardown to separate conditions passed by the --skip_teardown_conditions flag into three toke...
Parses the skip_teardown_conditions flag. Used by the validator below and flag_util.ShouldTeardown to separate conditions passed by the --skip_teardown_conditions flag into three tokens: metric, lower bound, upper_bound Initial regex parsing captures a metric (any string before a > or <), direction (the...
ParseSkipTeardownConditions
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def MetricMeetsConditions( metric_sample: Mapping[str, Any], conditions: Mapping[str, Mapping[str, float | None]], ) -> bool: """Checks if a metric sample meets any conditions. If a metric falls within the bounds of a condition, log the metric and the condition. Args: metric_sample: The metric sam...
Checks if a metric sample meets any conditions. If a metric falls within the bounds of a condition, log the metric and the condition. Args: metric_sample: The metric sample to check conditions: The conditions to check against Returns: True if the metric sample meets any of the conditions, False o...
MetricMeetsConditions
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def _InjectBenchmarkInfoIntoDocumentation(): """Appends each benchmark's information to the main module's docstring.""" # TODO: Verify if there is other way of appending additional help # message. # Inject more help documentation # The following appends descriptions of the benchmarks and descriptions of # t...
Appends each benchmark's information to the main module's docstring.
_InjectBenchmarkInfoIntoDocumentation
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def _ParseFlags(argv): """Parses the command-line flags and returns the positional arguments.""" try: argv = FLAGS(argv) if len(argv) > 1: raise flags.ValidationError( f'Unexpected positional arguments: {argv[1:]}' ) return argv except flags.Error as e: logging.error(e) l...
Parses the command-line flags and returns the positional arguments.
_ParseFlags
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def _PrintHelp(matches=None): """Prints help for flags defined in matching modules. Args: matches: regex string or None. Filters help to only those whose name matched the regex. If None then all flags are printed. """ if not matches: print(FLAGS) else: flags_by_module = FLAGS.flags_by_modul...
Prints help for flags defined in matching modules. Args: matches: regex string or None. Filters help to only those whose name matched the regex. If None then all flags are printed.
_PrintHelp
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def _PrintHelpMD(matches=None): """Prints markdown formatted help for flags defined in matching modules. Works just like --helpmatch. Args: matches: regex string or None. Filters help to only those whose name matched the regex. If None then all flags are printed. Raises: RuntimeError: If unable...
Prints markdown formatted help for flags defined in matching modules. Works just like --helpmatch. Args: matches: regex string or None. Filters help to only those whose name matched the regex. If None then all flags are printed. Raises: RuntimeError: If unable to find module help. Eg: * all f...
_PrintHelpMD
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def _InitializeRunUri(): """Determines the PKB run URI and sets FLAGS.run_uri.""" if FLAGS.run_uri is None: if stages.PROVISION in FLAGS.run_stage: FLAGS.run_uri = str(uuid.uuid4())[-8:] else: # Attempt to get the last modified run directory. run_uri = vm_util.GetLastRunUri() if run_...
Determines the PKB run URI and sets FLAGS.run_uri.
_InitializeRunUri
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def _CreateBenchmarkSpecs(): """Create a list of BenchmarkSpecs for each benchmark run to be scheduled. Returns: A list of BenchmarkSpecs. """ specs = [] benchmark_tuple_list = benchmark_sets.GetBenchmarksFromFlags() benchmark_counts = collections.defaultdict(itertools.count) for benchmark_module, us...
Create a list of BenchmarkSpecs for each benchmark run to be scheduled. Returns: A list of BenchmarkSpecs.
_CreateBenchmarkSpecs
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def _WriteCompletionStatusFile(benchmark_specs, status_file): """Writes a completion status file. The file has one json object per line, each with the following format: { "name": <benchmark name>, "status": <completion status>, "failed_substatus": <failed substatus>, "status_detail": <descriptiv...
Writes a completion status file. The file has one json object per line, each with the following format: { "name": <benchmark name>, "status": <completion status>, "failed_substatus": <failed substatus>, "status_detail": <descriptive string (if present)>, "flags": <flags dictionary> } Args...
_WriteCompletionStatusFile
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def _SetRestoreSpec(spec: bm_spec.BenchmarkSpec) -> None: """Unpickles the spec to restore resources from, if provided.""" restore_path = pkb_flags.RESTORE_PATH.value if restore_path: logging.info('Using restore spec at path: %s', restore_path) with open(restore_path, 'rb') as spec_file: spec.restor...
Unpickles the spec to restore resources from, if provided.
_SetRestoreSpec
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def _SetFreezePath(spec: bm_spec.BenchmarkSpec) -> None: """Sets the path to freeze resources to if provided.""" if pkb_flags.FREEZE_PATH.value: spec.freeze_path = pkb_flags.FREEZE_PATH.value logging.info('Using freeze path, %s', spec.freeze_path)
Sets the path to freeze resources to if provided.
_SetFreezePath
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def DoProvisionPhase( spec: bm_spec.BenchmarkSpec, timer: timing_util.IntervalTimer ): """Performs the Provision phase of benchmark execution. Args: spec: The BenchmarkSpec created for the benchmark. timer: An IntervalTimer that measures the start and stop times of resource provisioning. """ ...
Performs the Provision phase of benchmark execution. Args: spec: The BenchmarkSpec created for the benchmark. timer: An IntervalTimer that measures the start and stop times of resource provisioning.
DoProvisionPhase
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def __init__(self, vms): """Start check interrupt thread. Args: vms: A list of virtual machines. """ self.vms = vms self.check_threads = [] self.phase_status = threading.Event() for vm in vms: if vm.IsInterruptible(): check_thread = threading.Thread(target=self.CheckInte...
Start check interrupt thread. Args: vms: A list of virtual machines.
__init__
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def CheckInterrupt(self, vm): """Check interrupt. Args: vm: the virtual machine object. Returns: None """ while not self.phase_status.is_set(): vm.UpdateInterruptibleVmStatus(use_api=False) if vm.WasInterrupted(): return else: self.phase_status.wait(vm...
Check interrupt. Args: vm: the virtual machine object. Returns: None
CheckInterrupt
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def EndCheckInterruptThreadAndRaiseError(self): """End check interrupt thread and raise error. Raises: InsufficientCapacityCloudFailure when it catches interrupt. Returns: None """ self.EndCheckInterruptThread() if any(vm.IsInterruptible() and vm.WasInterrupted() for vm in self.vms...
End check interrupt thread and raise error. Raises: InsufficientCapacityCloudFailure when it catches interrupt. Returns: None
EndCheckInterruptThreadAndRaiseError
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def DoPreparePhase( spec: bm_spec.BenchmarkSpec, timer: timing_util.IntervalTimer ): """Performs the Prepare phase of benchmark execution. Args: spec: The BenchmarkSpec created for the benchmark. timer: An IntervalTimer that measures the start and stop times of the benchmark module's Prepare func...
Performs the Prepare phase of benchmark execution. Args: spec: The BenchmarkSpec created for the benchmark. timer: An IntervalTimer that measures the start and stop times of the benchmark module's Prepare function.
DoPreparePhase
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def DoRunPhase( spec: bm_spec.BenchmarkSpec, collector: publisher.SampleCollector, timer: timing_util.IntervalTimer, ): """Performs the Run phase of benchmark execution. Args: spec: The BenchmarkSpec created for the benchmark. collector: The SampleCollector object to add samples to. timer: ...
Performs the Run phase of benchmark execution. Args: spec: The BenchmarkSpec created for the benchmark. collector: The SampleCollector object to add samples to. timer: An IntervalTimer that measures the start and stop times of the benchmark module's Run function.
DoRunPhase
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def DoCleanupPhase( spec: bm_spec.BenchmarkSpec, timer: timing_util.IntervalTimer ): """Performs the Cleanup phase of benchmark execution. Cleanup phase work should be delegated to spec.BenchmarkCleanup to allow non-PKB based cleanup if needed. Args: spec: The BenchmarkSpec created for the benchmark. ...
Performs the Cleanup phase of benchmark execution. Cleanup phase work should be delegated to spec.BenchmarkCleanup to allow non-PKB based cleanup if needed. Args: spec: The BenchmarkSpec created for the benchmark. timer: An IntervalTimer that measures the start and stop times of the benchmark modu...
DoCleanupPhase
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def DoTeardownPhase( spec: bm_spec.BenchmarkSpec, collector: publisher.SampleCollector, timer: timing_util.IntervalTimer, ): """Performs the Teardown phase of benchmark execution. Teardown phase work should be delegated to spec.Delete to allow non-PKB based teardown if needed. Args: spec: The ...
Performs the Teardown phase of benchmark execution. Teardown phase work should be delegated to spec.Delete to allow non-PKB based teardown if needed. Args: spec: The BenchmarkSpec created for the benchmark. collector: The SampleCollector object to add samples to (if collecting delete samples) ...
DoTeardownPhase
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def _PublishStageStartedSamples( sender: str, benchmark_spec: bm_spec.BenchmarkSpec ): """Publish the start of each stage.""" if sender == stages.PROVISION and pkb_flags.CREATE_STARTED_RUN_SAMPLE.value: _PublishRunStartedSample(benchmark_spec) if pkb_flags.CREATE_STARTED_STAGE_SAMPLES.value: _PublishE...
Publish the start of each stage.
_PublishStageStartedSamples
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def _PublishRunStartedSample(spec): """Publishes a sample indicating that a run has started. This sample is published immediately so that there exists some metric for any run (even if the process dies). Args: spec: The BenchmarkSpec object with run information. """ metadata = {'flags': str(flag_util.G...
Publishes a sample indicating that a run has started. This sample is published immediately so that there exists some metric for any run (even if the process dies). Args: spec: The BenchmarkSpec object with run information.
_PublishRunStartedSample
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def _PublishEventSample( spec: bm_spec.BenchmarkSpec, event: str, metadata: Dict[str, Any] | None = None, collector: publisher.SampleCollector | None = None, ): """Publishes a sample indicating the progress of the benchmark. Value of sample is time of event in unix seconds Args: spec: The Be...
Publishes a sample indicating the progress of the benchmark. Value of sample is time of event in unix seconds Args: spec: The BenchmarkSpec object with run information. event: The progress event to publish. metadata: optional metadata to publish about the event. collector: the SampleCollector to u...
_PublishEventSample
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def _IsException(e: Exception, exception_class: Type[Exception]) -> bool: """Checks if the exception is of the class or contains the class name. When exceptions happen on on background theads (e.g. CreationInternalError on CreateAndBootVm) they are not propogated as exceptions to the caller, instead they are p...
Checks if the exception is of the class or contains the class name. When exceptions happen on on background theads (e.g. CreationInternalError on CreateAndBootVm) they are not propogated as exceptions to the caller, instead they are propagated as text inside a wrapper exception such as errors.VmUtil.ThreadExce...
_IsException
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def RunBenchmark( spec: bm_spec.BenchmarkSpec, collector: publisher.SampleCollector ): """Runs a single benchmark and adds the results to the collector. Args: spec: The BenchmarkSpec object with run information. collector: The SampleCollector object to add samples to. """ # Since there are issues ...
Runs a single benchmark and adds the results to the collector. Args: spec: The BenchmarkSpec object with run information. collector: The SampleCollector object to add samples to.
RunBenchmark
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def PublishFailedRunSample( spec: bm_spec.BenchmarkSpec, error_message: str, run_stage_that_failed: str, collector: publisher.SampleCollector, ): """Publish a sample.Sample representing a failed run stage. The sample metric will have the name 'Run Failed'; the value will be the timestamp in Unix ...
Publish a sample.Sample representing a failed run stage. The sample metric will have the name 'Run Failed'; the value will be the timestamp in Unix Seconds, and the unit will be 'seconds'. The sample metadata will include the error message from the Exception, the run stage that failed, as well as all PKB ...
PublishFailedRunSample
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def _ShouldRetry(spec: bm_spec.BenchmarkSpec) -> bool: """Returns whether the benchmark run should be retried.""" return ( spec.status == benchmark_status.FAILED and spec.failed_substatus in _RETRY_SUBSTATUSES.value )
Returns whether the benchmark run should be retried.
_ShouldRetry
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def _GetMachineTypes(spec: bm_spec.BenchmarkSpec) -> list[str]: """Returns a deduped list of machine types to provision for the given spec.""" if FLAGS.machine_type: return [FLAGS.machine_type] results = set() for vm_group_spec in spec.vms_to_boot.values(): results.add(vm_group_spec.vm_spec.machine_type...
Returns a deduped list of machine types to provision for the given spec.
_GetMachineTypes
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def RunBenchmarkTask( spec: bm_spec.BenchmarkSpec, ) -> Tuple[Sequence[bm_spec.BenchmarkSpec], List[sample.SampleDict]]: """Task that executes RunBenchmark. This is designed to be used with RunParallelProcesses. Note that for retries only the last run has its samples published. Arguments: spec: Benchm...
Task that executes RunBenchmark. This is designed to be used with RunParallelProcesses. Note that for retries only the last run has its samples published. Arguments: spec: BenchmarkSpec. The spec to call RunBenchmark with. Returns: A BenchmarkSpec for each run iteration and a list of samples from the...
RunBenchmarkTask
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def _SetOriginalZoneAndFlag(self) -> None: """Records the flag name and zone value that the benchmark started with.""" # This is guaranteed to set values due to flag validator. self._supported_zones = self._utils.GetZonesFromMachineType( self._machine_types[0] ) for machine_type in self._mac...
Records the flag name and zone value that the benchmark started with.
_SetOriginalZoneAndFlag
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def HandleSmartRetries(self, spec: bm_spec.BenchmarkSpec) -> None: """Handles smart zone retry flags if provided. If quota retry, pick zone in new region. If unsupported or stockout retries, pick zone in same region. Args: spec: benchmark spec. """ if ( pkb_flags.SMART_QUOTA_RETR...
Handles smart zone retry flags if provided. If quota retry, pick zone in new region. If unsupported or stockout retries, pick zone in same region. Args: spec: benchmark spec.
HandleSmartRetries
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def _AssignZoneToNewRegion(self) -> None: """Changes zone to be a new zone in the different region.""" region = self._utils.GetRegionFromZone(self._GetCurrentZoneFlag()) self._regions_tried.add(region) regions_to_try = ( { self._utils.GetRegionFromZone(zone) for zone in s...
Changes zone to be a new zone in the different region.
_AssignZoneToNewRegion
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def _AssignZoneToSameRegion(self) -> None: """Changes zone to be a new zone in the same region.""" supported_zones_in_region = self._utils.GetZonesInRegion( self._original_region ).intersection(self._supported_zones) self._ChooseAndSetNewZone(supported_zones_in_region)
Changes zone to be a new zone in the same region.
_AssignZoneToSameRegion
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def _ChooseAndSetNewZone(self, possible_zones: Set[str]) -> None: """Saves the current _zone_flag and sets it to a new zone. Args: possible_zones: The set of zones to choose from. """ current_zone = self._GetCurrentZoneFlag() if current_zone != _ANY_ZONE: self._zones_tried.add(current_z...
Saves the current _zone_flag and sets it to a new zone. Args: possible_zones: The set of zones to choose from.
_ChooseAndSetNewZone
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def SetUpPKB(): """Set globals and environment variables for PKB. After SetUpPKB() returns, it should be possible to call PKB functions, like benchmark_spec.Prepare() or benchmark_spec.Run(). SetUpPKB() also modifies the local file system by creating a temp directory and storing new SSH keys. """ try: ...
Set globals and environment variables for PKB. After SetUpPKB() returns, it should be possible to call PKB functions, like benchmark_spec.Prepare() or benchmark_spec.Run(). SetUpPKB() also modifies the local file system by creating a temp directory and storing new SSH keys.
SetUpPKB
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def RunBenchmarks(): """Runs all benchmarks in PerfKitBenchmarker. Returns: Exit status for the process. """ benchmark_specs = _CreateBenchmarkSpecs() if FLAGS.randomize_run_order: random.shuffle(benchmark_specs) if FLAGS.dry_run: print('PKB will run with the following configurations:') for...
Runs all benchmarks in PerfKitBenchmarker. Returns: Exit status for the process.
RunBenchmarks
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def _GenerateBenchmarkDocumentation(): """Generates benchmark documentation to show in --help.""" benchmark_docs = [] for benchmark_module in ( linux_benchmarks.BENCHMARKS + windows_benchmarks.BENCHMARKS ): benchmark_config = configs.LoadMinimalConfig( benchmark_module.BENCHMARK_CONFIG, ...
Generates benchmark documentation to show in --help.
_GenerateBenchmarkDocumentation
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def _CreateCpuVulnerabilitySamples(vms) -> List[sample.Sample]: """Returns samples of the VMs' CPU vulernabilites.""" def CreateSample(vm) -> sample.Sample | None: metadata = {'vm_name': vm.name} metadata.update(vm.cpu_vulnerabilities.asdict) return sample.Sample('cpu_vuln', 0, '', metadata) linux_v...
Returns samples of the VMs' CPU vulernabilites.
_CreateCpuVulnerabilitySamples
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def _CreateGccSamples(vms): """Creates samples from linux VMs of gcc version output.""" def _GetGccMetadata(vm): return { 'name': vm.name, 'versiondump': build_tools.GetVersion(vm, 'gcc'), 'versioninfo': build_tools.GetVersionInfo(vm, 'gcc'), } linux_vms = [vm for vm in vms if vm...
Creates samples from linux VMs of gcc version output.
_CreateGccSamples
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def _CreateGlibcSamples(vms): """Creates glibc samples from linux VMs of ldd output.""" def _GetGlibcVersionInfo(vm): out, _ = vm.RemoteCommand('ldd --version', ignore_failure=True) # return first line return out.splitlines()[0] if out else None def _GetGlibcMetadata(vm): return { 'name'...
Creates glibc samples from linux VMs of ldd output.
_CreateGlibcSamples
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def _ParseMeminfo(meminfo_txt: str) -> Tuple[Dict[str, int], List[str]]: """Returns the parsed /proc/meminfo data. Response has entries such as {'MemTotal' : 32887056, 'Inactive': 4576524}. If the /proc/meminfo entry has two values such as MemTotal: 32887056 kB checks that the last value is 'kB' If it is n...
Returns the parsed /proc/meminfo data. Response has entries such as {'MemTotal' : 32887056, 'Inactive': 4576524}. If the /proc/meminfo entry has two values such as MemTotal: 32887056 kB checks that the last value is 'kB' If it is not then adds that line to the 2nd value in the tuple. Args: meminfo_t...
_ParseMeminfo
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def _CollectMeminfoHandler( unused_sender, benchmark_spec: bm_spec.BenchmarkSpec, samples: List[sample.Sample], ) -> None: """Optionally creates /proc/meminfo samples. If the flag --collect_meminfo is set appends a sample.Sample of /proc/meminfo data for every VM in the run. Parameter names cannot...
Optionally creates /proc/meminfo samples. If the flag --collect_meminfo is set appends a sample.Sample of /proc/meminfo data for every VM in the run. Parameter names cannot be changed as the method is called by events.send with keyword arguments. Args: benchmark_spec: The benchmark spec. samples: G...
_CollectMeminfoHandler
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def _CollectLsmemHandler( unused_sender, benchmark_spec: bm_spec.BenchmarkSpec, samples: List[sample.Sample], ) -> None: """Optionally creates lsmem sample of VM total memory. If the flag --collect_lsmem is set, this function appends a sample.Sample of total memory size. Parameter names cannot b...
Optionally creates lsmem sample of VM total memory. If the flag --collect_lsmem is set, this function appends a sample.Sample of total memory size. Parameter names cannot be changed as the method is called by events.send with keyword arguments. Args: benchmark_spec: The benchmark spec. samples: G...
_CollectLsmemHandler
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/pkb.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/pkb.py
Apache-2.0
def __init__(self, placement_group_spec): """Initialize BasePlacementGroup class. Args: placement_group_spec: placement_group.BasePlacementGroupSpec object of the placement group. """ super().__init__() self.zone = placement_group_spec.zone
Initialize BasePlacementGroup class. Args: placement_group_spec: placement_group.BasePlacementGroupSpec object of the placement group.
__init__
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/placement_group.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/placement_group.py
Apache-2.0
def PublishRunStageSamples(benchmark_spec, samples): """Publishes benchmark run-stage samples immediately. Typically, a benchmark publishes samples by returning them from the Run function so that they can be pubished at set points (publish periods or at the end of a run). This function can be called to publish...
Publishes benchmark run-stage samples immediately. Typically, a benchmark publishes samples by returning them from the Run function so that they can be pubished at set points (publish periods or at the end of a run). This function can be called to publish the samples immediately. Note that metadata for the ru...
PublishRunStageSamples
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/publisher.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/publisher.py
Apache-2.0
def GetLabelsFromDict(metadata: dict[Any, Any]) -> str: """Converts a metadata dictionary to a string of labels sorted by key. Args: metadata: a dictionary of string key value pairs. Returns: A string of labels, sorted by key, in the format that Perfkit uses. """ labels = [] for k, v in sorted(met...
Converts a metadata dictionary to a string of labels sorted by key. Args: metadata: a dictionary of string key value pairs. Returns: A string of labels, sorted by key, in the format that Perfkit uses.
GetLabelsFromDict
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/publisher.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/publisher.py
Apache-2.0
def LabelsToDict(labels_str: str) -> dict[str, str]: """Deserializes labels from string. Meant to invert GetLabelsFromDict(). Args: labels_str: The string encoding the labels. Returns: A python dictionary mapping label names to contents. """ # labels_str is of the form |k1:v1|,|k2:v2|. entries ...
Deserializes labels from string. Meant to invert GetLabelsFromDict(). Args: labels_str: The string encoding the labels. Returns: A python dictionary mapping label names to contents.
LabelsToDict
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/publisher.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/publisher.py
Apache-2.0
def _FindConstantMetadataKeys(self, samples): """Finds metadata keys which are constant across a collection of samples. Args: samples: List of dicts, as passed to SamplePublisher.PublishSamples. Returns: The set of metadata keys for which all samples in 'samples' have the same value. ...
Finds metadata keys which are constant across a collection of samples. Args: samples: List of dicts, as passed to SamplePublisher.PublishSamples. Returns: The set of metadata keys for which all samples in 'samples' have the same value.
_FindConstantMetadataKeys
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/publisher.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/publisher.py
Apache-2.0
def __init__(self, bucket, gsutil_path='gsutil', sub_folder=None): """CloudStoragePublisher constructor. Args: bucket: string. The GCS bucket name to publish to. gsutil_path: string. The path to the 'gsutil' tool. sub_folder: Optional folder within the bucket to publish to. """ super(...
CloudStoragePublisher constructor. Args: bucket: string. The GCS bucket name to publish to. gsutil_path: string. The path to the 'gsutil' tool. sub_folder: Optional folder within the bucket to publish to.
__init__
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/publisher.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/publisher.py
Apache-2.0
def __init__(self, es_uri=None, es_index=None, es_type=None): """ElasticsearchPublisher constructor. Args: es_uri: String. e.g. "http://localhost:9200" es_index: String. Default "perfkit" es_type: String. Default "result" """ super().__init__() self.es_uri = es_uri self.es_ind...
ElasticsearchPublisher constructor. Args: es_uri: String. e.g. "http://localhost:9200" es_index: String. Default "perfkit" es_type: String. Default "result"
__init__
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/publisher.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/publisher.py
Apache-2.0
def _FormatTimestampForElasticsearch(self, epoch_us): """Convert the floating epoch timestamp in micro seconds epoch_us to yyyy-MM-dd HH:mm:ss.SSSSSS in string """ ts = time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(epoch_us)) num_dec = ('%.6f' % (epoch_us - math.floor(epoch_us))).split('.')[1] ...
Convert the floating epoch timestamp in micro seconds epoch_us to yyyy-MM-dd HH:mm:ss.SSSSSS in string
_FormatTimestampForElasticsearch
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/publisher.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/publisher.py
Apache-2.0
def _deDotKeys(self, res): """Recursively replace dot with underscore in all keys in a dictionary.""" for key, value in res.items(): if isinstance(value, dict): self._deDotKeys(value) new_key = key.replace('.', '_') if new_key != key: res[new_key] = res.pop(key) return res
Recursively replace dot with underscore in all keys in a dictionary.
_deDotKeys
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/publisher.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/publisher.py
Apache-2.0
def _CreateDB(self): """Creates a database. This method is idempotent. If the DB already exists it will simply return a 200 code without re-creating it. """ successful_http_request_codes = [200, 202, 204] header = { 'Content-type': 'application/x-www-form-urlencoded', 'Accept': ...
Creates a database. This method is idempotent. If the DB already exists it will simply return a 200 code without re-creating it.
_CreateDB
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/publisher.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/publisher.py
Apache-2.0
def AddSamples(self, samples, benchmark, benchmark_spec): """Adds data samples to the publisher. Args: samples: A list of Sample objects. benchmark: string. The name of the benchmark. benchmark_spec: BenchmarkSpec. Benchmark specification. """ for s in samples: # Annotate the sa...
Adds data samples to the publisher. Args: samples: A list of Sample objects. benchmark: string. The name of the benchmark. benchmark_spec: BenchmarkSpec. Benchmark specification.
AddSamples
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/publisher.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/publisher.py
Apache-2.0
def PublishSamples(self): """Publish samples via all registered publishers.""" if not self.samples: logging.warning('No samples to publish.') return samples_for_console = [] for s in self.samples: if not s.get(pkb_sample.DISABLE_CONSOLE_LOG, False): samples_for_console.append(s...
Publish samples via all registered publishers.
PublishSamples
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/publisher.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/publisher.py
Apache-2.0
def RepublishJSONSamples(path): """Read samples from a JSON file and re-export them. Args: path: the path to the JSON file. """ with open(path) as file: samples = [json.loads(s) for s in file if s] for sample in samples: # Chop '|' at the beginning and end of labels and split labels by '|,|' ...
Read samples from a JSON file and re-export them. Args: path: the path to the JSON file.
RepublishJSONSamples
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/publisher.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/publisher.py
Apache-2.0
def ExtractGroup(regex, text, group=1, flags=0): """Extracts a string from a regular expression matched to 'text'. Args: regex: string or regexp pattern. Regular expression. text: string. Text to search. group: int. Group containing a floating point value. Use '0' for the whole string. flags:...
Extracts a string from a regular expression matched to 'text'. Args: regex: string or regexp pattern. Regular expression. text: string. Text to search. group: int. Group containing a floating point value. Use '0' for the whole string. flags: int. Flags to pass to re.search(). Returns: A ...
ExtractGroup
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/regex_util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/regex_util.py
Apache-2.0
def ExtractIpv4Addresses(text): """Extracts all ipv4 addresses within 'text'. Args: text: string. Text to search. Returns: A list of ipv4 strings. Raises: NoMatchError: when no ipv4 address is found. """ match = re.findall(_IPV4_REGEX, text) if not match: raise NoMatchError('No match for...
Extracts all ipv4 addresses within 'text'. Args: text: string. Text to search. Returns: A list of ipv4 strings. Raises: NoMatchError: when no ipv4 address is found.
ExtractIpv4Addresses
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/regex_util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/regex_util.py
Apache-2.0
def ExtractAllMatches(regex: Union[str, re.Pattern[str]], text, flags=0): """Extracts all matches from a regular expression matched within 'text'. Extracts all matches from a regular expression matched within 'text'. Please note that this function will return a list of strings if regex does not contain any cap...
Extracts all matches from a regular expression matched within 'text'. Extracts all matches from a regular expression matched within 'text'. Please note that this function will return a list of strings if regex does not contain any capturing groups, matching the behavior of re.findall: >>> re.findall(r'bar', 'f...
ExtractAllMatches
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/regex_util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/regex_util.py
Apache-2.0
def ExtractExactlyOneMatch(regex, text): """Extracts exactly one match of a regular expression from 'text'. Args: regex: string. Regular expression, possibly with capturing group. text: string. The text to search. Returns: The contents of the capturing group in the regex. If no capturing group i...
Extracts exactly one match of a regular expression from 'text'. Args: regex: string. Regular expression, possibly with capturing group. text: string. The text to search. Returns: The contents of the capturing group in the regex. If no capturing group is present, the text that matched the expressio...
ExtractExactlyOneMatch
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/regex_util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/regex_util.py
Apache-2.0
def Substitute(pattern, repl, text): """Substitute all 'pattern' in 'text' with 'repl'. Args: pattern: string. Pattern to be replaced. repl: string. Replacement pattern. text: string. Text to search. Returns: A string after replacing all patterns with repl. Raises: NoMatchError: when 'patt...
Substitute all 'pattern' in 'text' with 'repl'. Args: pattern: string. Pattern to be replaced. repl: string. Replacement pattern. text: string. Text to search. Returns: A string after replacing all patterns with repl. Raises: NoMatchError: when 'pattern' isn't found in string.
Substitute
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/regex_util.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/regex_util.py
Apache-2.0
def GetRelationalDbClass(cloud, is_managed_db, engine): """Get the RelationalDb class corresponding to 'cloud'. Args: cloud: name of cloud to get the class for is_managed_db: is the database self managed or database a a service engine: database engine type Returns: BaseRelationalDb class with th...
Get the RelationalDb class corresponding to 'cloud'. Args: cloud: name of cloud to get the class for is_managed_db: is the database self managed or database a a service engine: database engine type Returns: BaseRelationalDb class with the cloud attribute of 'cloud'.
GetRelationalDbClass
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/relational_db.py
Apache-2.0
def __init__(self, relational_db_spec): """Initialize the managed relational database object. Args: relational_db_spec: spec of the managed database. """ super().__init__( enable_freeze_restore=relational_db_spec.enable_freeze_restore, create_on_restore_error=relational_db_spec.cr...
Initialize the managed relational database object. Args: relational_db_spec: spec of the managed database.
__init__
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/relational_db.py
Apache-2.0
def client_vm(self): """Client VM which will drive the database test. This is required by subclasses to perform client-vm network-specific tasks, such as getting information about the VPC, IP address, etc. Raises: RelationalDbPropertyNotSetError: if the client_vm is missing. Returns: ...
Client VM which will drive the database test. This is required by subclasses to perform client-vm network-specific tasks, such as getting information about the VPC, IP address, etc. Raises: RelationalDbPropertyNotSetError: if the client_vm is missing. Returns: The client_vm.
client_vm
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/relational_db.py
Apache-2.0
def client_vm_query_tools_for_replica(self): """Query tools to make custom queries on replica.""" if not self.replica_endpoint: raise ValueError('Database does not have replica.') connection_properties = sql_engine_utils.DbConnectionProperties( self.spec.engine, self.spec.engine_versio...
Query tools to make custom queries on replica.
client_vm_query_tools_for_replica
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/relational_db.py
Apache-2.0
def port(self): """Port (int) on which the database server is listening.""" if not hasattr(self, '_port'): raise RelationalDbPropertyNotSetError('port not set') return self._port
Port (int) on which the database server is listening.
port
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/relational_db.py
Apache-2.0
def GetResourceMetadata(self): """Returns a dictionary of metadata. Child classes can extend this if needed. Raises: RelationalDbPropertyNotSetError: if any expected metadata is missing. """ metadata = { 'zone': self.spec.db_spec.zone, 'disk_type': self.spec.db_disk_spec.dis...
Returns a dictionary of metadata. Child classes can extend this if needed. Raises: RelationalDbPropertyNotSetError: if any expected metadata is missing.
GetResourceMetadata
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/relational_db.py
Apache-2.0
def GetDefaultEngineVersion(self, engine): """Return the default version (for PKB) for the given database engine. Args: engine: name of the database engine Returns: default version as a string for the given engine. """
Return the default version (for PKB) for the given database engine. Args: engine: name of the database engine Returns: default version as a string for the given engine.
GetDefaultEngineVersion
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/relational_db.py
Apache-2.0
def GetDefaultPort(self): """Returns default port for the db engine from the spec.""" engine = sql_engine_utils.GetDbEngineType(self.spec.engine) if engine not in DEFAULT_PORTS: raise NotImplementedError( 'Default port not specified for engine {}'.format(engine) ) return DEFAULT_PO...
Returns default port for the db engine from the spec.
GetDefaultPort
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/relational_db.py
Apache-2.0
def Failover(self): """Fail over the database. Throws exception if not high available.""" if not self.spec.high_availability: raise RuntimeError( "Attempt to fail over a database that isn't marked as high available" ) self._FailoverHA()
Fail over the database. Throws exception if not high available.
Failover
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/relational_db.py
Apache-2.0
def GetRelationalDbSpecClass(engine): """Get the RelationalDbSpec class corresponding to 'engine'.""" if engine in [ sql_engine_utils.SPANNER_GOOGLESQL, sql_engine_utils.SPANNER_POSTGRES, ]: return spec.GetSpecClass(RelationalDbSpec, SERVICE_TYPE='spanner') return RelationalDbSpec
Get the RelationalDbSpec class corresponding to 'engine'.
GetRelationalDbSpecClass
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/relational_db_spec.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/relational_db_spec.py
Apache-2.0
def _CheckRequirements(requirements_file_path): """Checks that all package requirements specified in a file are met. Args: requirements_file_path: string. Path to a pip requirements file. """ with open(requirements_file_path) as fp: requirements_to_check = [(requirements_file_path, deque(fp.readlines()...
Checks that all package requirements specified in a file are met. Args: requirements_file_path: string. Path to a pip requirements file.
_CheckRequirements
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/requirements.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/requirements.py
Apache-2.0
def CheckBasicRequirements(): """Checks that all basic package requirements are met. The basic requirements include packages used by modules that are imported regardless of the specified cloud providers. The list of required packages and versions is found in the requirements.txt file in the git branch's root ...
Checks that all basic package requirements are met. The basic requirements include packages used by modules that are imported regardless of the specified cloud providers. The list of required packages and versions is found in the requirements.txt file in the git branch's root directory. If such a file does not...
CheckBasicRequirements
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/requirements.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/requirements.py
Apache-2.0
def CheckProviderRequirements(provider): """Checks that all provider-specific requirements are met. The provider-specific requirements include packages used by modules that are imported when using a particular cloud provider. The list of required packages is found in the requirements-<provider>.txt file in the...
Checks that all provider-specific requirements are met. The provider-specific requirements include packages used by modules that are imported when using a particular cloud provider. The list of required packages is found in the requirements-<provider>.txt file in the git branch's root directory. If such a file...
CheckProviderRequirements
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/requirements.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/requirements.py
Apache-2.0
def GetResourceClass(base_class: ResourceType, **kwargs) -> ResourceType: """Returns the subclass with the corresponding attributes. Args: base_class: The base class of the resource to return (e.g. BaseVirtualMachine). **kwargs: Every attribute/value of the subclass's REQUIRED_ATTRS that were u...
Returns the subclass with the corresponding attributes. Args: base_class: The base class of the resource to return (e.g. BaseVirtualMachine). **kwargs: Every attribute/value of the subclass's REQUIRED_ATTRS that were used to register the subclass. Raises: Exception: If no class could be fo...
GetResourceClass
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/resource.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resource.py
Apache-2.0
def Restore(self) -> None: """Restores a resource instead of creating it. Raises: RestoreError: Generic error encompassing restore failures. """ # TODO(user): Add usage lock with labels to prevent multiple # benchmarks from using the same resource concurrently. logging.info('Restoring res...
Restores a resource instead of creating it. Raises: RestoreError: Generic error encompassing restore failures.
Restore
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/resource.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resource.py
Apache-2.0
def Create(self, restore: bool = False) -> None: """Creates a resource and its dependencies. Args: restore: Whether to restore the resource instead of creating. If enable_freeze_restore is false, this proceeds with creation. Raises: RestoreError: If there is an error while restoring. ...
Creates a resource and its dependencies. Args: restore: Whether to restore the resource instead of creating. If enable_freeze_restore is false, this proceeds with creation. Raises: RestoreError: If there is an error while restoring.
Create
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/resource.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resource.py
Apache-2.0
def Freeze(self) -> None: """Freezes a resource instead of deleting it. Raises: FreezeError: Generic error encompassing freeze failures. """ logging.info('Freezing resource %s.', repr(self)) # Attempt to call freeze, failing if unimplemented. try: self._Freeze() except NotImplem...
Freezes a resource instead of deleting it. Raises: FreezeError: Generic error encompassing freeze failures.
Freeze
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/resource.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resource.py
Apache-2.0
def Delete(self, freeze: bool = False) -> None: """Deletes a resource and its dependencies. Args: freeze: Whether to freeze the resource instead of deleting. If enable_freeze_restore is false, this proceeds with deletion. Raises: FreezeError: If there is an error while freezing. ""...
Deletes a resource and its dependencies. Args: freeze: Whether to freeze the resource instead of deleting. If enable_freeze_restore is false, this proceeds with deletion. Raises: FreezeError: If there is an error while freezing.
Delete
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/resource.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resource.py
Apache-2.0
def UpdateTimeout(self, timeout_minutes: int) -> None: """Updates the timeout of the underlying resource. Args: timeout_minutes: The number of minutes past the current time at which the resource should be considered expired. Raises: NotImplementedError: If the resource has not implemen...
Updates the timeout of the underlying resource. Args: timeout_minutes: The number of minutes past the current time at which the resource should be considered expired. Raises: NotImplementedError: If the resource has not implemented _UpdateTimeout().
UpdateTimeout
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/resource.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resource.py
Apache-2.0
def GetSamples(self) -> List[sample.Sample]: """Get samples relating to the provisioning of the resource.""" # This should not be necessary. Resources are responsible to wire their # GetResourceMetadata into publisher.py, but some do not. metadata = self.GetResourceMetadata() metadata['resource_type...
Get samples relating to the provisioning of the resource.
GetSamples
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/resource.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/resource.py
Apache-2.0
def PercentileCalculator(numbers, percentiles=PERCENTILES_LIST): """Computes percentiles, stddev and mean on a set of numbers. Args: numbers: A sequence of numbers to compute percentiles for. percentiles: If given, a list of percentiles to compute. Can be floats, ints or longs. Returns: A dict...
Computes percentiles, stddev and mean on a set of numbers. Args: numbers: A sequence of numbers to compute percentiles for. percentiles: If given, a list of percentiles to compute. Can be floats, ints or longs. Returns: A dictionary of percentiles. Raises: ValueError, if numbers is empty ...
PercentileCalculator
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/sample.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/sample.py
Apache-2.0
def GeoMean(iterable): """Calculate the geometric mean of a collection of numbers. Args: iterable: A sequence of numbers. Returns: The geometric mean Raises: ValueError, if numbers is empty. """ arr = np.fromiter(iterable, dtype='float') if not arr.size: raise ValueError("Can't compute ...
Calculate the geometric mean of a collection of numbers. Args: iterable: A sequence of numbers. Returns: The geometric mean Raises: ValueError, if numbers is empty.
GeoMean
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/sample.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/sample.py
Apache-2.0
def MakeHistogram( values: List[float], round_bottom: float = 0.0, round_to_sig_fig: int = 3 ) -> _Histogram[float, int]: """Take a list of float values and returns a ordered dict of values and frequency. Args: values: a list of float values round_bottom: A float between 0 and 1 indicating a percentile...
Take a list of float values and returns a ordered dict of values and frequency. Args: values: a list of float values round_bottom: A float between 0 and 1 indicating a percentile of values that should be rounded. Any values below this percentile will be rounded according to the precision specifie...
MakeHistogram
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/sample.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/sample.py
Apache-2.0
def CreateHistogramSample( histogram: _Histogram[float, int], name: str, subname: str, units: str, additional_metadata=None, metric='', ) -> Sample: """Given a histogram of values, create a sample. Args: histogram: an ordered dict of objects name: name of histogram subname: subn...
Given a histogram of values, create a sample. Args: histogram: an ordered dict of objects name: name of histogram subname: subname of histogram units: the units of measure used in the sample additional_metadata: any additional metadata to add metric: metric in the sample Returns: sampl...
CreateHistogramSample
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/sample.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/sample.py
Apache-2.0
def CreateTimeSeriesSample( values: List[Any], timestamps: List[float], metric: str, units: str, interval: float, ramp_up_ends=None, ramp_down_starts=None, additional_metadata=None, ) -> Sample: """Create time series samples. Given a list of values and the timestamp the values cr...
Create time series samples. Given a list of values and the timestamp the values created at create a time series samples. Each value correspond to the timestamp that the value is collected. The size of the values and timestamps have to be equal. Args: values: an value orderd based on time series tim...
CreateTimeSeriesSample
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/sample.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/sample.py
Apache-2.0
def replica_vms(self): """Server VM of replicas for hosting a managed database. Raises: RelationalDbPropertyNotSetError: if the server_vm is missing. Returns: The replica vms. """ if not hasattr(self, "_replica_vms"): raise relational_db.RelationalDbPropertyNotSetError( ...
Server VM of replicas for hosting a managed database. Raises: RelationalDbPropertyNotSetError: if the server_vm is missing. Returns: The replica vms.
replica_vms
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/sqlserver_iaas_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/sqlserver_iaas_relational_db.py
Apache-2.0
def ConfirmFlags(self): """Confirm flags to make sure all the requirements are met.""" # If high availability mode, set high availability type if needed if self.spec.high_availability and self.spec.high_availability_type is None: self.spec.high_availability_type = "FCIS2D"
Confirm flags to make sure all the requirements are met.
ConfirmFlags
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/sqlserver_iaas_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/sqlserver_iaas_relational_db.py
Apache-2.0
def MoveSQLServerTempDb(self): """Moves the SQL Server temporary database to LocalSSD.""" vms = [self.server_vm] if self.spec.high_availability_type == "AOAG" and self.replica_vms: vms.extend(self.replica_vms) # Moves the SQL Server temporary database to LocalSSD. for vm in vms: stdout,...
Moves the SQL Server temporary database to LocalSSD.
MoveSQLServerTempDb
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/sqlserver_iaas_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/sqlserver_iaas_relational_db.py
Apache-2.0
def _SetEndpoint(self): """Set the DB endpoint for this instance during _PostCreate.""" super()._SetEndpoint() if self.spec.high_availability: perf_domain = "perf" + FLAGS.run_uri[:6] self.endpoint = "fcidnn.{}.local".format(perf_domain) else: self.endpoint = self.server_vm.internal_ip
Set the DB endpoint for this instance during _PostCreate.
_SetEndpoint
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/sqlserver_iaas_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/sqlserver_iaas_relational_db.py
Apache-2.0
def ConfigureSQLServerHaFci(self): """Create SQL server HA deployment for performance testing.""" server_vm = self.server_vm client_vm = self.client_vm controller_vm = self.controller_vm replica_vms = self.replica_vms win_password = vm_util.GenerateRandomWindowsPassword( vm_util.PASSWOR...
Create SQL server HA deployment for performance testing.
ConfigureSQLServerHaFci
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/sqlserver_iaas_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/sqlserver_iaas_relational_db.py
Apache-2.0
def EnsurePrimaryReplica(self): """Move server_vm as primary node in AOAG.""" # Set first server vm as primary if necessary out, _ = self.server_vm.RemoteCommand( """sqlcmd -Q \" SELECT role_desc FROM sys.dm_hadr_availability_replica_states ars JOIN sys....
Move server_vm as primary node in AOAG.
EnsurePrimaryReplica
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/sqlserver_iaas_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/sqlserver_iaas_relational_db.py
Apache-2.0
def PushAndRunPowershellScript( self, vm: virtual_machine.VirtualMachine, script_name: str, cmd_parameters: list[str] | None = None, source_path: str = "relational_db_configs/sqlserver_ha_configs/", ) -> tuple[str, str]: """Pushes a powershell script to VM and run it. Args: ...
Pushes a powershell script to VM and run it. Args: vm: vm where script will be uploaded and executed script_name: name of the script to upload and execute cmd_parameters: optional command parameters source_path: script source location Returns: command execution output.
PushAndRunPowershellScript
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/sqlserver_iaas_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/sqlserver_iaas_relational_db.py
Apache-2.0
def RestartDatabase(self): """Restarts all the database services in the benchmark.""" vms = [self.server_vm] if self.spec.high_availability and self.replica_vms: vms.append(self.replica_vms) for vm in vms: if vm.BASE_OS_TYPE == os_types.WINDOWS: vm.RemoteCommand("Restart-Service MSSQ...
Restarts all the database services in the benchmark.
RestartDatabase
python
GoogleCloudPlatform/PerfKitBenchmarker
perfkitbenchmarker/sqlserver_iaas_relational_db.py
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/master/perfkitbenchmarker/sqlserver_iaas_relational_db.py
Apache-2.0