Really simple patch to get the CPU count out of an OSX box for automatic
--parallel setting for mtr2.
For my drizzle MTR2 port, I fixed up the command line parsing of
--parallel to use the automatic detection if no --parallel was detected.
Should apply to a MySQL tree without an issue as this file is unchanged
in my mtr2 port for Drizzle.
------------------------------------------------------------
revno: 1097
committer: Stewart Smith <stewart@stripped>
branch nick: mtr2
timestamp: Mon 2009-06-15 18:33:46 +1000
message:
CPU count detection for mtr2 on MacOS X
diff:
=== modified file 'tests/lib/My/SysInfo.pm'
--- tests/lib/My/SysInfo.pm 2009-06-13 00:19:46 +0000
+++ tests/lib/My/SysInfo.pm 2009-06-15 08:33:46 +0000
@@ -111,6 +111,33 @@
return undef;
}
+# hostinfo as found on MacOS X
+sub _hostinfo {
+ my ($self)= @_;
+
+ my $hostinfo= `hostinfo`;
+
+ $hostinfo =~ /^(\d+) processors are logically available/m;
+
+ my $ncpus= $1;
+
+ foreach(1..$ncpus)
+ {
+ my $cpuinfo = { };
+
+ # Make sure bogomips is set to some value
+ $cpuinfo->{bogomips} |= DEFAULT_BOGO_MIPS;
+
+ push (@{$self->{cpus}}, $cpuinfo);
+ }
+
+ if ( $self->{cpus} ) {
+ return $self;
+ }
+
+ return undef;
+}
+
sub new {
my ($class)= @_;
@@ -125,6 +152,7 @@
\&_cpuinfo,
\&_kstat,
\&_unamex,
+ \&_hostinfo,
);
# Detect virtual machines
--
Stewart Smith