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
Exemple #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
 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)
Exemple #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)
Exemple #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))
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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()
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)