Skip to content

Commit

Permalink
Changes:
Browse files Browse the repository at this point in the history
	- implement the TestTask.overhead property that returns a float value representing non-group time.
  • Loading branch information
worldomonation committed Jul 16, 2020
1 parent 737c4cc commit 1a26793
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions mozci/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
import json
import os
from abc import ABC, abstractmethod
from argparse import Namespace
from dataclasses import dataclass, field
from enum import Enum
from inspect import signature
from statistics import median
from typing import Dict, List, Optional

import requests
from adr.query import run_query
from adr.util import memoized_property
from loguru import logger
from urllib3.response import HTTPResponse
Expand Down Expand Up @@ -358,6 +360,21 @@ def configuration(self):
parts = config.split("-")
return "-".join(parts[:-1] if parts[-1].isdigit() else parts)

@property
def overhead(self):
"""Calculate the overhead of a task.
The methodology is simple: each task is associated with a duration value.
Obtain and sum the runtime of all groups in the task, then take the
difference and we have the overhead value.
Returns:
float: Difference of task duration and sum of group durations.
"""
data = run_query("group_durations", Namespace(task_id=self.id))["data"]
group_runtime = [runtime for *_, runtime in data]
return self.duration - sum(group_runtime)


# Don't perform type checking because of https://github.com/python/mypy/issues/5374.
@dataclass # type: ignore
Expand Down

0 comments on commit 1a26793

Please sign in to comment.