Package org.openjdk.jmh.util
Class Utils
java.lang.Object
org.openjdk.jmh.util.Utils
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Iterable
<T> adaptForLoop
(Iterator<T> it) Adapts Iterator for Iterable.static void
static void
static String[]
static int
Warm up the CPU schedulers, bring all the CPUs online to get the reasonable estimate of the system capacity.static String
static String
static String
static long
static long
getPid()
Gets PID of the current JVM.static long
Gets the PID of the target process.static Properties
We don't access the complete system properties viaSystem.getProperties()
because this would require read/write permissions to the properties.static Charset
private static void
indent
(PrintWriter pw, int indent) static boolean
static String
static String
join
(Collection<String> src, String delim) static String
marshalIntArray
(int[] arr) static <T extends Comparable<T>>
Tmax
(Collection<T> ts) static <T extends Comparable<T>>
Tmin
(Collection<T> ts) static Properties
static void
reflow
(PrintWriter pw, String src, int width, int indent) static Collection
<String> static int
roundUp
(int v, int quant) static Process
static Collection
<String> private static void
setAccessible
(Object holder, AccessibleObject o) static Collection
<String> splitQuotedEscape
(String src) static int
sum
(int[] arr) static String
static Collection
<String> static int[]
unmarshalIntArray
(String src)
-
Field Details
-
U
private static final sun.misc.Unsafe U
-
-
Constructor Details
-
Utils
private Utils()
-
-
Method Details
-
min
-
max
-
concat
-
join
-
join
-
splitQuotedEscape
-
sum
public static int sum(int[] arr) -
roundUp
public static int roundUp(int v, int quant) -
throwableToString
-
unmarshalIntArray
-
marshalIntArray
-
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
-
setAccessible
- Throws:
IllegalAccessException
-
guessConsoleEncoding
-
reflow
-
indent
-
rewrap
-
check
-
check
-
getOffset
-
isWindows
public static boolean isWindows() -
getCurrentJvm
-
getCurrentJvmVersion
-
getCurrentOSVersion
-
getPid
public static long getPid()Gets PID of the current JVM.- Returns:
- PID.
-
getPid
Gets the PID of the target process.- Parameters:
process
- to poll- Returns:
- PID, or zero if no PID is found
-
tryWith
-
runAsync
-
runWith
-
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
-
adaptForLoop
Adapts Iterator for Iterable. Can be iterated only once!- Type Parameters:
T
- element type- Parameters:
it
- iterator- Returns:
- iterable for given iterator
-