Ejemplo n.º 1
0
    def handle_metadata_message(self, variant, *args, **kwargs):
        metadata = self.metadata
        if metadata is None:
            metadata = {}

        if variant == 'taskwarrior.execute':
            if 'taskwarrior' not in metadata:
                metadata['taskwarrior'] = {}
            if 'execute' not in metadata['taskwarrior']:
                metadata['taskwarrior']['execute'] = []
            metadata['taskwarrior']['execute'].append(
                args[0]
            )

        all_durations = [
            v['duration'] for v in metadata['taskwarrior']['execute']
        ]
        stats = {}
        if len(all_durations) > 1:
            stats.update({
                'max': max(all_durations),
                'min': min(all_durations),
                'stdev': statistics.stdev(all_durations),
                'mean': statistics.mean(all_durations),
                'sum': sum(all_durations),
            })
        metadata['taskwarrior']['statistics'] = stats

        self.metadata = metadata
Ejemplo n.º 2
0
    def handle_metadata_message(self, variant, *args, **kwargs):
        metadata = self.metadata
        if metadata is None:
            metadata = {}

        if variant == 'taskwarrior.execute':
            if 'taskwarrior' not in metadata:
                metadata['taskwarrior'] = {}
            if 'execute' not in metadata['taskwarrior']:
                metadata['taskwarrior']['execute'] = []
            metadata['taskwarrior']['execute'].append(
                args[0]
            )

        all_durations = [
            v['duration'] for v in metadata['taskwarrior']['execute']
        ]
        stats = {}
        if len(all_durations) > 1:
            stats.update({
                'max': max(all_durations),
                'min': min(all_durations),
                'stdev': statistics.stdev(all_durations),
                'mean': statistics.mean(all_durations),
                'sum': sum(all_durations),
            })
        metadata['taskwarrior']['statistics'] = stats

        self.metadata = metadata
Ejemplo n.º 3
0
 def time_to_first_byte(self):
     """
     The aggregate time to first byte for all pages.
     """
     ttfb = []
     for page in self.pages:
         ttfb.append(page.time_to_first_byte)
     return round(mean(ttfb), self.decimal_precision)
Ejemplo n.º 4
0
 def time_to_first_byte(self):
     """
     The aggregate time to first byte for all pages.
     """
     ttfb = []
     for page in self.pages:
         ttfb.append(page.time_to_first_byte)
     return round(mean(ttfb), self.decimal_precision)
Ejemplo n.º 5
0
def calculate_len_mean(iterable):
    """
    >>> calculate_len_mean(['abc', 'd', 'ef'])
    2.0
    >>> calculate_len_mean(['abcde', 'fgh', 'ij'])
    3.3333333333333335
    >>> calculate_len_mean([[1, 2, 3], [4], [5, 6]])
    2.0
    """
    return mean(map(len, iterable))
Ejemplo n.º 6
0
 def html_load_time(self):
     """
     Returns aggregate html load time for all pages.
     """
     load_times = self.get_load_times('html')
     return round(mean(load_times), self.decimal_precision)
Ejemplo n.º 7
0
 def video_load_time(self):
     """
     Returns aggregate video load time for all pages.
     """
     load_times = self.get_load_times('video')
     return round(mean(load_times), self.decimal_precision)
Ejemplo n.º 8
0
 def html_load_time(self):
     """
     Returns aggregate html load time for all pages.
     """
     load_times = self.get_load_times('html')
     return round(mean(load_times), self.decimal_precision)
Ejemplo n.º 9
0
 def image_load_time(self):
     """
     Returns aggregate image load time for all pages.
     """
     load_times = self.get_load_times('image')
     return round(mean(load_times), self.decimal_precision)
Ejemplo n.º 10
0
 def css_load_time(self):
     """
     Returns aggregate css load time for all pages.
     """
     load_times = self.get_load_times('css')
     return round(mean(load_times), self.decimal_precision)
Ejemplo n.º 11
0
 def js_load_time(self):
     """
     Returns aggregate javascript load time.
     """
     load_times = self.get_load_times('js')
     return round(mean(load_times), self.decimal_precision)
Ejemplo n.º 12
0
 def page_load_time(self):
     """
     The average total load time for all runs (not weighted).
     """
     load_times = self.get_load_times('page')
     return round(mean(load_times), self.decimal_precision)
Ejemplo n.º 13
0
 def video_load_time(self):
     """
     Returns aggregate video load time for all pages.
     """
     load_times = self.get_load_times('video')
     return round(mean(load_times), self.decimal_precision)
Ejemplo n.º 14
0
# ---

>>> l = range(10)
>>> l[:3] = []
>>> l
[3, 4, 5, 6, 7, 8, 9]


# ---
"""
3.4 から標準ライブラリに statistics が入ってる
"""
from backports.statistics import mean

mean([1, 3, 5])
mean(range(1, 10))

# ---
"""
単語の平均文字数を調べる
"""
from nltk.corpus import brown
words = brown.words(categories='adventure')
mean(map(len, words))

# ---
"""
カテゴリを調べる
"""
brown.categories()
Ejemplo n.º 15
0
 def image_load_time(self):
     """
     Returns aggregate image load time for all pages.
     """
     load_times = self.get_load_times('image')
     return round(mean(load_times), self.decimal_precision)
Ejemplo n.º 16
0
 def css_load_time(self):
     """
     Returns aggregate css load time for all pages.
     """
     load_times = self.get_load_times('css')
     return round(mean(load_times), self.decimal_precision)
Ejemplo n.º 17
0
 def js_load_time(self):
     """
     Returns aggregate javascript load time.
     """
     load_times = self.get_load_times('js')
     return round(mean(load_times), self.decimal_precision)
Ejemplo n.º 18
0
 def page_load_time(self):
     """
     The average total load time for all runs (not weighted).
     """
     load_times = self.get_load_times('page')
     return round(mean(load_times), self.decimal_precision)