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.
	- add new query to obtain start/end times for the group and task.
  • Loading branch information
worldomonation committed Jul 16, 2020
1 parent 737c4cc commit 4f4d24c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
11 changes: 11 additions & 0 deletions mozci/queries/test_task_overhead.query
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from: unittest
format: list
groupby: task.id
limit: 20000
select:
- {value: action.start_time, name: task_min, aggregate: min}
- {value: action.end_time, name: task_max, aggregate: max}
- {value: result.start_time, name: group_min, aggregate: min}
- {value: result.end_time, name: group_max, aggregate: max}
where:
- in: {task.id: {$eval: task_id}}
26 changes: 26 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,30 @@ 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 (action) has a start/end time.
Each group also has a start/end time. Take the earlist known group start
and latest known group end time, ensure the two falls somewhere in between
task start/end.
Then calculate the overhead by taking the difference between the start
and end times.
Returns:
float: difference between task start/end and group star/end times.
"""
data = run_query("test_task_overhead", Namespace(task_id=self.id))["data"].pop()
# Sanity check to ensure group start/end times are within task start/end.
assert data["task_min"] < data["group_min"]
assert data["task_max"] > data["group_max"]

return (data["group_min"] - data["task_min"]) + (
data["task_max"] - data["group_max"]
)


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

0 comments on commit 4f4d24c

Please sign in to comment.