Skip to content

Instantly share code, notes, and snippets.

@nicoulaj
Created September 6, 2012 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicoulaj/3659659 to your computer and use it in GitHub Desktop.
Save nicoulaj/3659659 to your computer and use it in GitHub Desktop.
Runtime.availableProcessors() gives info about available resources, not affinity which occurs at scheduling level
#!/bin/sh
cat > PrintAvailableProcs.java <<EOF
public class PrintAvailableProcs {
public static void main(String[] args) {
System.out.println(Runtime.getRuntime().availableProcessors());
}
}
EOF
javac PrintAvailableProcs.java
echo "cpuinfo: $(grep -c processor /proc/cpuinfo)"
echo "java: $(java PrintAvailableProcs)"
echo "bound with taskset: $(taskset -c 0 java PrintAvailableProcs)"
echo "bound with numactl: $(numactl -C 0 java PrintAvailableProcs)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment