List:Internals« Previous MessageNext Message »
From:Stewart Smith Date:June 15 2009 8:36am
Subject:mtr2 CPU detection for MacOS X
View as plain text  
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
Thread
mtr2 CPU detection for MacOS XStewart Smith15 Jun
  • Re: mtr2 CPU detection for MacOS XKristian Nielsen15 Jun
    • Re: mtr2 CPU detection for MacOS XStewart Smith8 Jul
  • Re: mtr2 CPU detection for MacOS XStewart Smith8 Jul