From 87209f2547a4e07fe6ccb55f0665d792c341c5a0 Mon Sep 17 00:00:00 2001 From: Sabrina Krakau Date: Fri, 4 Aug 2023 15:21:13 +0200 Subject: [PATCH 1/8] Fix def Double --- .../main/nextflow/co2footprint/CO2FootprintFactory.groovy | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy index c185f5c..2ec66f4 100644 --- a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy +++ b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy @@ -183,14 +183,12 @@ class CO2FootprintFactory implements TraceObserverFactory { /** * Calculate energy consumption [kWh] */ - def Double e = (t * (nc * pc * uc + nm * pm) * pue * 0.001) as Double - log.info "E: $e" + Double e = (t * (nc * pc * uc + nm * pm) * pue * 0.001) as Double /* * Resulting CO2 emission [gCO2e] */ - def Double c = (e * ci) as Double - log.info "CO2: $c" + Double c = (e * ci) // Return values in mWh and mg e = e * 1000000 From b29b6dd3dea212cdffea53a1662e164019c93c88 Mon Sep 17 00:00:00 2001 From: Sabrina Krakau Date: Fri, 4 Aug 2023 15:36:57 +0200 Subject: [PATCH 2/8] Add further task-specific params to TXT output --- .../co2footprint/CO2FootprintFactory.groovy | 101 +++++++++++++----- .../nextflow/co2footprint/CO2Record.groovy | 34 +++++- 2 files changed, 106 insertions(+), 29 deletions(-) diff --git a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy index 2ec66f4..4c4a17c 100644 --- a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy +++ b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy @@ -127,24 +127,20 @@ class CO2FootprintFactory implements TraceObserverFactory { // Factor 0.001 needed to convert Pc and Pm from W to kW // t: runtime in hours - def t = (trace.get('realtime') as Double)/3600000 - log.info "t: $t" + Double t = (trace.get('realtime') as Double)/3600000 as Double /** * Factors of core power usage */ // nc: number of cores - def nc = trace.get('cpus') as Integer - log.info "nc: $nc" + Double nc = trace.get('cpus') as Integer // Pc: power draw of a computing core [W] - def pc = getCpuCoreTdp(trace) - log.info "pc: $pc" + Double pc = getCpuCoreTdp(trace) // uc: core usage factor (between 0 and 1) // TODO if requested more than used, this is not taken into account, right? - def cpu_usage = trace.get('%cpu') as Double - log.info "cpu_usage: $cpu_usage" + Double cpu_usage = trace.get('%cpu') as Double if ( cpu_usage == null ) { log.info "cpu_usage is null" // TODO why is value null, because task was finished so fast that it was not captured? Or are there other reasons? @@ -152,9 +148,8 @@ class CO2FootprintFactory implements TraceObserverFactory { cpu_usage = nc * 100 } // TODO how to handle double, Double datatypes for ceiling? - def cpus_ceil = Math.ceil( cpu_usage / 100.0 as double ) - def uc = cpu_usage / (100.0 * cpus_ceil) - log.info "uc: $uc" + Double cpus_ceil = Math.ceil( cpu_usage / 100.0 as double ) + Double uc = cpu_usage / (100.0 * cpus_ceil) as Double /** * Factors of memory power usage @@ -165,18 +160,17 @@ class CO2FootprintFactory implements TraceObserverFactory { log.error "TraceRecord field 'memory' is not set!" System.exit(1) } - def nm = (trace.get('memory') as Long)/1000000000 - log.info "nm: $nm" + Double nm = (trace.get('memory') as Long)/1000000000 as Double // TODO handle if more memory/cpus used than requested? // Pm: power draw of memory [W per GB] - def pm = config.getPowerdrawMem() + Double pm = config.getPowerdrawMem() /** * Remaining factors */ // PUE: efficiency coefficient of the data centre - def pue = config.getPUE() + Double pue = config.getPUE() // CI: carbon intensity [gCO2e kWh−1] def ci = config.getCI() @@ -194,7 +188,7 @@ class CO2FootprintFactory implements TraceObserverFactory { e = e * 1000000 c = c * 1000 - return [e, c] + return [e, c, t, nc, pc, uc, nm] } @@ -275,7 +269,17 @@ class CO2FootprintFactory implements TraceObserverFactory { writer = new Agent(co2eFile) summaryWriter = new Agent(co2eSummaryFile) - writer.send { co2eFile.println("task_id\tenergy_consumption\tCO2e"); co2eFile.flush() } + writer.send { co2eFile.println( + "task_id\t" + + "energy_consumption\t" + + "CO2e\t" + + "time\t" + + "cpus\t" + + "powerdraw_cpu\t" + + "cpu_usage\t" + + "requested_memory" + ); co2eFile.flush() + } } /** @@ -344,15 +348,38 @@ class CO2FootprintFactory implements TraceObserverFactory { def computation_results = computeTaskCO2footprint(trace) def eConsumption = computation_results[0] def co2 = computation_results[1] - - - - co2eRecords[taskId] = new CO2Record((Double) eConsumption, (Double) co2, trace.get('name').toString()) + def time = computation_results[2] + def cpus = computation_results[3] as Integer + def powerdrawCPU = computation_results[4] + def cpu_usage = computation_results[5] + def memory = computation_results[6] + + co2eRecords[taskId] = new CO2Record( + (Double) eConsumption, + (Double) co2, + (Double) time, + cpus, + (Double) powerdrawCPU, + (Double) cpu_usage, + (Double) memory, + trace.get('name').toString() + ) total_energy += eConsumption total_co2 += co2 // save to the file - writer.send { PrintWriter it -> it.println("${taskId}\t${HelperFunctions.convertToReadableUnits(eConsumption,3)}Wh\t${HelperFunctions.convertToReadableUnits(co2,3)}g"); it.flush() } + writer.send { + PrintWriter it -> it.println( + "${taskId}\t${HelperFunctions.convertToReadableUnits(eConsumption,3)}Wh\t" + + "${HelperFunctions.convertToReadableUnits(co2,3)}g\t" + + "${time}h\t" + + "${cpus}\t" + + "${powerdrawCPU}\t" + + "${cpu_usage}\t" + + "${memory}GB\t" + ); + it.flush() + } } @@ -368,12 +395,38 @@ class CO2FootprintFactory implements TraceObserverFactory { def computation_results = computeTaskCO2footprint(trace) def eConsumption = computation_results[0] def co2 = computation_results[1] - co2eRecords[taskId] = new CO2Record((Double) eConsumption, (Double) co2, trace.get('name').toString()) + def time = computation_results[2] + def cpus = computation_results[3] as Integer + def powerdrawCPU = computation_results[4] + def cpu_usage = computation_results[5] + def memory = computation_results[6] + + co2eRecords[taskId] = new CO2Record( + (Double) eConsumption, + (Double) co2, + (Double) time, + cpus, + (Double) powerdrawCPU, + (Double) cpu_usage, + (Double) memory, + trace.get('name').toString() + ) total_energy += eConsumption total_co2 += co2 // save to the file - writer.send { PrintWriter it -> it.println("${taskId}\t${HelperFunctions.convertToReadableUnits(eConsumption,3)}Wh\t${HelperFunctions.convertToReadableUnits(co2,3)}g"); it.flush() } + writer.send { + PrintWriter it -> it.println( + "${taskId}\t${HelperFunctions.convertToReadableUnits(eConsumption,3)}Wh\t" + + "${HelperFunctions.convertToReadableUnits(co2,3)}g" + + "${time}h\t" + + "${cpus}\t" + + "${powerdrawCPU}\t" + + "${cpu_usage}\t" + + "${memory}GB\t" + ); + it.flush() + } } } diff --git a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2Record.groovy b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2Record.groovy index 4f15fa8..23c3521 100644 --- a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2Record.groovy +++ b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2Record.groovy @@ -18,20 +18,44 @@ class CO2Record extends TraceRecord { private Double energy private Double co2e + private Double time + private Integer cpus + private Double powerdrawCPU + private Double cpuUsage + private Double memory private String name // final? or something? to make sure for key value can be set only once? - CO2Record(Double energy, Double co2e, String name) { + CO2Record(Double energy, Double co2e, Double time, Integer cpus, Double powerdrawCPU, Double cpuUsage, Double memory, String name) { this.energy = energy this.co2e = co2e + this.time = time + this.cpus = cpus + this.powerdrawCPU = powerdrawCPU + this.cpuUsage = cpuUsage + this.memory = memory this.name = name - this.store = new LinkedHashMap<>(['energy': energy, 'co2e': co2e, 'name': name]) + this.store = new LinkedHashMap<>([ + 'energy': energy, + 'co2e': co2e, + 'time': time, + 'co2e': co2e, + 'powerdrawCPU': powerdrawCPU, + 'cpuUsage': cpuUsage, + 'memory': memory, + 'name': name + ]) } final public static Map FIELDS = [ - co2e: 'num', - energy: 'num', - name: 'str' + energy: 'num', + co2e: 'num', + time: 'num', + cpus: 'num', + powerdrawCPU: 'num', + cpuUsage: 'num', + memory: 'num', + name: 'str' ] // TODO implement accordingly to TraceRecord From 04b8c0797933eafb5fb52e2b369fda38fcb87cad Mon Sep 17 00:00:00 2001 From: Sabrina Krakau Date: Mon, 7 Aug 2023 10:41:41 +0200 Subject: [PATCH 3/8] Store memory in bytes and add convertBytesToReadableUnits() --- .../co2footprint/CO2FootprintFactory.groovy | 17 +++++++++-------- .../main/nextflow/co2footprint/CO2Record.groovy | 4 ++-- .../co2footprint/utils/HelperFunctions.groovy | 13 ++++++++++++- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy index 4c4a17c..1129942 100644 --- a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy +++ b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy @@ -155,12 +155,13 @@ class CO2FootprintFactory implements TraceObserverFactory { * Factors of memory power usage */ // nm: size of memory available [GB] -> requested memory - if ( trace.get('memory') == null ) { + Long memory = trace.get('memory') as Long + if ( memory == null ) { // TODO if 'memory' not set, returns null, hande somehow? log.error "TraceRecord field 'memory' is not set!" System.exit(1) } - Double nm = (trace.get('memory') as Long)/1000000000 as Double + Double nm = memory/1000000000 as Double // TODO handle if more memory/cpus used than requested? // Pm: power draw of memory [W per GB] @@ -188,7 +189,7 @@ class CO2FootprintFactory implements TraceObserverFactory { e = e * 1000000 c = c * 1000 - return [e, c, t, nc, pc, uc, nm] + return [e, c, t, nc, pc, uc, memory] } @@ -361,7 +362,7 @@ class CO2FootprintFactory implements TraceObserverFactory { cpus, (Double) powerdrawCPU, (Double) cpu_usage, - (Double) memory, + (Long) memory, trace.get('name').toString() ) total_energy += eConsumption @@ -376,7 +377,7 @@ class CO2FootprintFactory implements TraceObserverFactory { + "${cpus}\t" + "${powerdrawCPU}\t" + "${cpu_usage}\t" - + "${memory}GB\t" + + "${HelperFunctions.convertBytesToReadableUnits(memory)}" ); it.flush() } @@ -408,7 +409,7 @@ class CO2FootprintFactory implements TraceObserverFactory { cpus, (Double) powerdrawCPU, (Double) cpu_usage, - (Double) memory, + (Long) memory, trace.get('name').toString() ) total_energy += eConsumption @@ -418,12 +419,12 @@ class CO2FootprintFactory implements TraceObserverFactory { writer.send { PrintWriter it -> it.println( "${taskId}\t${HelperFunctions.convertToReadableUnits(eConsumption,3)}Wh\t" - + "${HelperFunctions.convertToReadableUnits(co2,3)}g" + + "${HelperFunctions.convertToReadableUnits(co2,3)}g\t" + "${time}h\t" + "${cpus}\t" + "${powerdrawCPU}\t" + "${cpu_usage}\t" - + "${memory}GB\t" + + "${HelperFunctions.convertBytesToReadableUnits(memory)}" ); it.flush() } diff --git a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2Record.groovy b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2Record.groovy index 23c3521..7f1a33a 100644 --- a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2Record.groovy +++ b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2Record.groovy @@ -22,11 +22,11 @@ class CO2Record extends TraceRecord { private Integer cpus private Double powerdrawCPU private Double cpuUsage - private Double memory + private Long memory private String name // final? or something? to make sure for key value can be set only once? - CO2Record(Double energy, Double co2e, Double time, Integer cpus, Double powerdrawCPU, Double cpuUsage, Double memory, String name) { + CO2Record(Double energy, Double co2e, Double time, Integer cpus, Double powerdrawCPU, Double cpuUsage, Long memory, String name) { this.energy = energy this.co2e = co2e this.time = time diff --git a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/utils/HelperFunctions.groovy b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/utils/HelperFunctions.groovy index 4bddf78..a1d9d1d 100644 --- a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/utils/HelperFunctions.groovy +++ b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/utils/HelperFunctions.groovy @@ -3,7 +3,7 @@ package nextflow.co2footprint public class HelperFunctions { static public String convertToReadableUnits(double value, int unitIndex=4) { - def units = ['p', 'n', 'u', 'm', ' ', 'K', 'M', 'G', 'T', 'P', 'E'] // Units: pico, nano, micro, mili, 0, Kilo, Mega, Giga, Tera, Peta, Exa + def units = ['p', 'n', 'u', 'm', ' ', 'K', 'M', 'G', 'T', 'P', 'E'] // Units: pico, nano, micro, milli, 0, Kilo, Mega, Giga, Tera, Peta, Exa while (value >= 1000 && unitIndex < units.size() - 1) { value /= 1000 @@ -17,4 +17,15 @@ public class HelperFunctions { return "${value}${units[unitIndex]}" } + static public String convertBytesToReadableUnits(double value) { + def units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'] // Units: pico, nano, micro, milli, 0, Kilo, Mega, Giga, Tera, Peta, Exa + int unitIndex=0 + + while (value >= 1024 && unitIndex < units.size() - 1) { + value /= 1024 + unitIndex++ + } + + return "${value} ${units[unitIndex]}" + } } \ No newline at end of file From 8de005309b05c46ac8400c667ba08976f994d21e Mon Sep 17 00:00:00 2001 From: Sabrina Krakau Date: Mon, 7 Aug 2023 11:46:57 +0200 Subject: [PATCH 4/8] Store time as ms and add convertion for txt output --- .../co2footprint/CO2FootprintFactory.groovy | 9 +++++---- .../co2footprint/utils/HelperFunctions.groovy | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy index 1129942..05699b4 100644 --- a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy +++ b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy @@ -127,7 +127,8 @@ class CO2FootprintFactory implements TraceObserverFactory { // Factor 0.001 needed to convert Pc and Pm from W to kW // t: runtime in hours - Double t = (trace.get('realtime') as Double)/3600000 as Double + Double realtime = trace.get('realtime') as Double + Double t = realtime/3600000 as Double /** * Factors of core power usage @@ -189,7 +190,7 @@ class CO2FootprintFactory implements TraceObserverFactory { e = e * 1000000 c = c * 1000 - return [e, c, t, nc, pc, uc, memory] + return [e, c, realtime, nc, pc, uc, memory] } @@ -373,7 +374,7 @@ class CO2FootprintFactory implements TraceObserverFactory { PrintWriter it -> it.println( "${taskId}\t${HelperFunctions.convertToReadableUnits(eConsumption,3)}Wh\t" + "${HelperFunctions.convertToReadableUnits(co2,3)}g\t" - + "${time}h\t" + + "${HelperFunctions.convertMillisecondsToReadableUnits(time)}\t" + "${cpus}\t" + "${powerdrawCPU}\t" + "${cpu_usage}\t" @@ -420,7 +421,7 @@ class CO2FootprintFactory implements TraceObserverFactory { PrintWriter it -> it.println( "${taskId}\t${HelperFunctions.convertToReadableUnits(eConsumption,3)}Wh\t" + "${HelperFunctions.convertToReadableUnits(co2,3)}g\t" - + "${time}h\t" + + "${HelperFunctions.convertMillisecondsToReadableUnits(time)}\t" + "${cpus}\t" + "${powerdrawCPU}\t" + "${cpu_usage}\t" diff --git a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/utils/HelperFunctions.groovy b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/utils/HelperFunctions.groovy index a1d9d1d..7e37aab 100644 --- a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/utils/HelperFunctions.groovy +++ b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/utils/HelperFunctions.groovy @@ -28,4 +28,22 @@ public class HelperFunctions { return "${value} ${units[unitIndex]}" } + + static public String convertMillisecondsToReadableUnits(double value) { + if ( value < 1000 ) { + return "${value}ms" + } else { + int h = Math.floor(value/3600000) + int m = Math.floor((value % 3600000)/60000) + int s = Math.floor((value % 60000)/1000) + + if ( value < 60000 ) + return "${s}s" + else if ( value < 3600000 ) + return "${m}m ${s}s" + else + return "${h}h ${m}m ${s}s" + } + // TODO also convert to days etc. or could we keep it like this? + } } \ No newline at end of file From 2191d4a019e64f1c81a9f8eb565e3ee56b40c8f1 Mon Sep 17 00:00:00 2001 From: Sabrina Krakau Date: Mon, 7 Aug 2023 11:50:02 +0200 Subject: [PATCH 5/8] Add space in txt output before unit --- .../src/main/nextflow/co2footprint/utils/HelperFunctions.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/utils/HelperFunctions.groovy b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/utils/HelperFunctions.groovy index 7e37aab..4cedd5e 100644 --- a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/utils/HelperFunctions.groovy +++ b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/utils/HelperFunctions.groovy @@ -14,7 +14,7 @@ public class HelperFunctions { unitIndex-- } - return "${value}${units[unitIndex]}" + return "${value} ${units[unitIndex]}" } static public String convertBytesToReadableUnits(double value) { From 4de815134a8eee5ea289dad75419e08a1269d6e9 Mon Sep 17 00:00:00 2001 From: Sabrina Krakau Date: Tue, 8 Aug 2023 15:36:21 +0200 Subject: [PATCH 6/8] Change Floats to Doubles --- .../main/nextflow/co2footprint/CO2FootprintConfig.groovy | 2 +- .../main/nextflow/co2footprint/CO2FootprintFactory.groovy | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintConfig.groovy b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintConfig.groovy index 4078387..336edea 100644 --- a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintConfig.groovy +++ b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintConfig.groovy @@ -42,7 +42,7 @@ class CO2FootprintConfig { while ( line = dataReader.readLine() ) { def row = line.split(",") if (row[0] == country) { - localCi = row[1].toFloat() + localCi = row[1].toDouble() break } } diff --git a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy index 05699b4..d0caf70 100644 --- a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy +++ b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/CO2FootprintFactory.groovy @@ -54,19 +54,19 @@ class CO2FootprintFactory implements TraceObserverFactory { final private Map co2eRecords = new ConcurrentHashMap<>() // TODO make sure for key value can be set only once? - private Map cpuData = ['default': (Float) 12.0] + private Map cpuData = ['default': (Double) 12.0] Double total_energy = 0 Double total_co2 = 0 // Load file containing TDP values for different CPU models - protected void loadCpuTdpData(Map data) { + protected void loadCpuTdpData(Map data) { def dataReader = new InputStreamReader(this.class.getResourceAsStream('/cpu_tdp_values.csv')) String line while ( line = dataReader.readLine() ) { def h = line.split(",") - if (h[0] != 'model_name') data[h[0]] = h[3].toFloat() + if (h[0] != 'model_name') data[h[0]] = h[3].toDouble() } dataReader.close() log.info "$data" @@ -93,7 +93,7 @@ class CO2FootprintFactory implements TraceObserverFactory { } - float getCpuCoreTdp(TraceRecord trace) { + Double getCpuCoreTdp(TraceRecord trace) { def cpu_model = trace.get('cpu_model').toString() // TODO toString() in TraceRecord get()? log.info "cpu model: $cpu_model" From e155d6b6f756b9adb9c48fb9c488f58dd3ad9985 Mon Sep 17 00:00:00 2001 From: Sabrina Krakau Date: Tue, 8 Aug 2023 15:48:16 +0200 Subject: [PATCH 7/8] Round values to two decimal places for output --- .../src/main/nextflow/co2footprint/utils/HelperFunctions.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/utils/HelperFunctions.groovy b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/utils/HelperFunctions.groovy index 4cedd5e..57c8421 100644 --- a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/utils/HelperFunctions.groovy +++ b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/utils/HelperFunctions.groovy @@ -13,7 +13,7 @@ public class HelperFunctions { value *= 1000 unitIndex-- } - + value = Math.round( value * 100 ) / 100 return "${value} ${units[unitIndex]}" } From a8c9425c2174bb302cf7b0a0f1f487c5ab95cb2d Mon Sep 17 00:00:00 2001 From: Sabrina Krakau Date: Wed, 9 Aug 2023 11:27:04 +0200 Subject: [PATCH 8/8] Update plugins/nf-co2footprint/src/main/nextflow/co2footprint/utils/HelperFunctions.groovy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Júlia Mir Pedrol --- .../src/main/nextflow/co2footprint/utils/HelperFunctions.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/utils/HelperFunctions.groovy b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/utils/HelperFunctions.groovy index 57c8421..43cf7a1 100644 --- a/plugins/nf-co2footprint/src/main/nextflow/co2footprint/utils/HelperFunctions.groovy +++ b/plugins/nf-co2footprint/src/main/nextflow/co2footprint/utils/HelperFunctions.groovy @@ -18,7 +18,7 @@ public class HelperFunctions { } static public String convertBytesToReadableUnits(double value) { - def units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'] // Units: pico, nano, micro, milli, 0, Kilo, Mega, Giga, Tera, Peta, Exa + def units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'] // Units: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte, Petabyte, Exabyte int unitIndex=0 while (value >= 1024 && unitIndex < units.size() - 1) {