Package org.openjdk.jmh.util
Class Utils
- java.lang.Object
-
- org.openjdk.jmh.util.Utils
-
public class Utils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Iterable<T>adaptForLoop(Iterator<T> it)Adapts Iterator for Iterable.static voidcheck(Class<?> klass, String fieldName)static voidcheck(Class<?> klass, String... fieldNames)static String[]concat(String[] t1, String[] t2)static intfigureOutHotCPUs()Warm up the CPU schedulers, bring all the CPUs online to get the reasonable estimate of the system capacity.static StringgetCurrentJvm()static StringgetCurrentJvmVersion()static StringgetCurrentOSVersion()static longgetOffset(Class<?> klass, String fieldName)static longgetPid()Gets PID of the current JVM.static longgetPid(Process process)Gets the PID of the target process.static PropertiesgetRecordedSystemProperties()We don't access the complete system properties viaSystem.getProperties()because this would require read/write permissions to the properties.static CharsetguessConsoleEncoding()static booleanisWindows()static Stringjoin(String[] src, String delim)static Stringjoin(Collection<String> src, String delim)static StringmarshalIntArray(int[] arr)static <T extends Comparable<T>>
Tmax(Collection<T> ts)static <T extends Comparable<T>>
Tmin(Collection<T> ts)static PropertiesreadPropertiesFromCommand(List<String> cmd)static voidreflow(PrintWriter pw, String src, int width, int indent)static Collection<String>rewrap(String lines)static introundUp(int v, int quant)static ProcessrunAsync(String... cmd)static Collection<String>runWith(List<String> cmd)static Collection<String>splitQuotedEscape(String src)static intsum(int[] arr)static StringthrowableToString(Throwable t)static Collection<String>tryWith(String... cmd)static int[]unmarshalIntArray(String src)
-
-
-
Method Detail
-
min
public static <T extends Comparable<T>> T min(Collection<T> ts)
-
max
public static <T extends Comparable<T>> T max(Collection<T> ts)
-
join
public static String join(Collection<String> src, String delim)
-
splitQuotedEscape
public static Collection<String> splitQuotedEscape(String src)
-
sum
public static int sum(int[] arr)
-
roundUp
public static int roundUp(int v, int quant)
-
unmarshalIntArray
public static int[] unmarshalIntArray(String src)
-
marshalIntArray
public static String marshalIntArray(int[] arr)
-
figureOutHotCPUs
public static int figureOutHotCPUs()
Warm up the CPU schedulers, bring all the CPUs online to get the reasonable estimate of the system capacity. Some systems, notably embedded Linuxes, power down the idle CPUs and so availableProcessors() may report lower CPU count than would be present after the load-up.- Returns:
- max CPU count
-
guessConsoleEncoding
public static Charset guessConsoleEncoding()
-
reflow
public static void reflow(PrintWriter pw, String src, int width, int indent)
-
rewrap
public static Collection<String> rewrap(String lines)
-
isWindows
public static boolean isWindows()
-
getCurrentJvm
public static String getCurrentJvm()
-
getCurrentJvmVersion
public static String getCurrentJvmVersion()
-
getCurrentOSVersion
public static String getCurrentOSVersion()
-
getPid
public static long getPid()
Gets PID of the current JVM.- Returns:
- PID.
-
getPid
public static long getPid(Process process)
Gets the PID of the target process.- Parameters:
process- to poll- Returns:
- PID, or zero if no PID is found
-
tryWith
public static Collection<String> tryWith(String... cmd)
-
runWith
public static Collection<String> runWith(List<String> cmd)
-
getRecordedSystemProperties
public static Properties getRecordedSystemProperties()
We don't access the complete system properties viaSystem.getProperties()because this would require read/write permissions to the properties. Just copy the properties we want to record in the result.- Returns:
- Copy of system properties we want to record in the results.
-
readPropertiesFromCommand
public static Properties readPropertiesFromCommand(List<String> cmd)
-
-