Mikhail Dubov 019eccb3d3 Create utils module for processing task results
Here we create a special rally.benchmark.processing.utils module for
computing a couple of useful functions on the benchmark data.

Change-Id: I9f3e6e50b9ba37946fbb56d7546b87b30beb0233
2014-04-29 12:06:13 +04:00

37 lines
1.2 KiB
Python

# Copyright 2014: Mirantis Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from rally.benchmark.processing import utils
from rally import exceptions
from tests import test
class ProcessingUtilsTestCase(test.TestCase):
def test_percentile(self):
lst = range(1, 101)
result = utils.percentile(lst, 0.1)
self.assertTrue(result == 10.9)
def test_mean(self):
lst = range(1, 100)
result = utils.mean(lst)
self.assertTrue(result == 50.0)
def test_mean_empty_list(self):
lst = []
self.assertRaises(exceptions.InvalidArgumentsException,
utils.mean, lst)