-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request 'New option to specify how long test should run.' …
…(#2) from time into main Reviewed-on: https://git.data.coop/nellemann/jnetperf/pulls/2
- Loading branch information
Showing
11 changed files
with
161 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
projectId = jnetperf | ||
projectGroup = biz.nellemann.jnetperf | ||
projectVersion = 0.0.7 | ||
projectVersion = 0.0.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/main/java/biz/nellemann/jnetperf/TimeSuffixConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package biz.nellemann.jnetperf; | ||
|
||
import picocli.CommandLine; | ||
|
||
import java.util.Locale; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
public class TimeSuffixConverter implements CommandLine.ITypeConverter<Integer> { | ||
|
||
final private Pattern pattern = Pattern.compile("(\\d+)([smh])?", Pattern.CASE_INSENSITIVE); | ||
|
||
public Integer convert(String value) { | ||
int seconds = 0; | ||
|
||
Matcher matcher = pattern.matcher(value); | ||
if (matcher.find()) { | ||
int number = Integer.parseInt(matcher.group(1)); | ||
if(matcher.group(2) != null) { // We got the second, minute or hour suffix | ||
String suffix = matcher.group(2); | ||
switch (suffix.toLowerCase(Locale.ROOT)) { | ||
case "s": | ||
seconds = number; | ||
break; | ||
case "m": | ||
seconds = number * 60; | ||
break; | ||
case "h": | ||
seconds = number * 60 * 60; | ||
break; | ||
default: | ||
System.err.println("Unknown suffix: " + suffix); | ||
seconds = number; | ||
} | ||
} else { | ||
seconds = number; | ||
} | ||
} | ||
return seconds; | ||
} | ||
|
||
} |
Oops, something went wrong.