From 2ce897a2e5460f2dbb7f40816f2fe1e042fa94e1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ma=C3=ABl=20Madon?= <mael.madon@irit.fr>
Date: Thu, 3 Nov 2022 16:34:44 +0100
Subject: [PATCH] better management of job grain

---
 swf2batsim_split_by_user.py | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/swf2batsim_split_by_user.py b/swf2batsim_split_by_user.py
index 1f44e9a..399499a 100755
--- a/swf2batsim_split_by_user.py
+++ b/swf2batsim_split_by_user.py
@@ -11,6 +11,7 @@ import re
 import sys
 import datetime
 import os
+from math import ceil
 
 from swf import SwfField
 
@@ -80,7 +81,7 @@ def generate_workload(input_swf, output_folder,
                     if user_id not in users:
                         users[user_id] = []
 
-                    profile = int(((run_time // job_grain) + 1) * job_grain)
+                    profile = int(ceil(run_time / job_grain) * job_grain)
 
                     job = (job_id, nb_res, run_time,
                            submit_time, profile, walltime)
@@ -169,17 +170,18 @@ def main():
                         action="store_true",
                         help="If set, only the given walltime in the trace "
                              "will be used")
-    parser.add_argument('-jg', '--job_grain',
-                        type=int, default=1,
-                        help="Selects the level of detail we want for jobs. "
-                             "This parameter is used to group jobs that have "
-                             "close running time")
-    parser.add_argument('-i', '--indent', type=int, default=None,
-                        help="If set to a non-negative integer, then JSON array "
-                             "elements and object members will be pretty-printed "
-                             "with that indent level. An indent level of 0, or "
-                             "negative, will only insert newlines. The default "
-                             "value (None) selects the most compact representation.")
+    parser.add_argument(
+        '-jg', '--job_grain', type=int, default=1,
+        help="Selects the level of detail we want for job profiles. "
+        "This parameter is used to group jobs that have close running times. "
+        "For example: a job grain of 10 will round up running times to the next ten.")
+    parser.add_argument(
+        '-i', '--indent', type=int, default=None,
+        help="If set to a non-negative integer, then JSON array "
+        "elements and object members will be pretty-printed "
+        "with that indent level. An indent level of 0, or "
+        "negative, will only insert newlines. The default "
+        "value (None) selects the most compact representation.")
 
     parser.add_argument("-q", "--quiet", action="store_true")
 
-- 
GitLab