Skip to content

Instantly share code, notes, and snippets.

@rh0dium
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rh0dium/414ed6ca567bdff2b57b to your computer and use it in GitHub Desktop.
Save rh0dium/414ed6ca567bdff2b57b to your computer and use it in GitHub Desktop.
Effort is the measure of what changed divided by the time it took to do it (Man Hours). For this we use the following strategy. If it is programatic code we look at the absolute lines of code that was edited, added and deleted negating comments. In the event it is binary data we look at the absolute file size delta. We divide this by the man ho…
def calculate_effort_hours(**kwargs):
"""Calculate effort hours on a file change.
The best situation is that we have a lines_delta, on known file types (*.c, *.v, *.va, etc.)
In lieu of that use the file size as the file_delta. time_difference is how long the file
was checked out as reported in journal file."""
code_lines_add = kwargs.get('code_lines_add', 0)
code_lines_add = int(code_lines_add) if code_lines_add is not None else 0
code_lines_minus = kwargs.get('code_lines_minus', 0)
code_lines_minus = int(code_lines_minus) if code_lines_minus is not None else 0
lines_delta = code_lines_add + code_lines_minus
file_size = kwargs.get('file_size', 0)
file_size = int(file_size) if file_size is not None else 0
prev_file_size = kwargs.get('prev_file_size', 0)
prev_file_size = int(prev_file_size) if prev_file_size is not None else 0
filesize_byte_delta = abs(file_size - prev_file_size)
# We prefer line delta
effort_delta = lines_delta if lines_delta else filesize_byte_delta
man_minutes = max([kwargs.get('man_hours', 0.0), 1/60.0]) * 60 # 1/2 sec
effort = (effort_delta / man_minutes) * \
EFFORT_DATA_SCALER.get(kwargs.get('vendor_datatype', None), 1) * \
EFFORT_ACTION_SCALER.get(kwargs.get('action', None), 1)
return effort / 60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment