Автор Тема: Трябвами някакъв тест за производителност  (Прочетена 1886 пъти)

Yasen6275

  • Напреднали
  • *****
  • Публикации: 553
    • Профил
Искам да сравня две дистрибуции как се справят с изчисления, дисков трансвер, работа с паметта. Какво да ползвам за целта?
Активен

ivak

  • Напреднали
  • *****
  • Публикации: 156
    • Профил
за дисковия трансфер ползвай iozone. на страницата на проекта има данни за цял куп тествани системи.

за работа с паметта мога да ти предложа следната програма:
Примерен код

// memory speed benchmark.
// started: december 2003
//
// written by Ivaylo Kroumov.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// 1. Redistributions of source code must retain the above copyright
//    notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
//    notice, this list of conditions and the following disclaimer in the
//    documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
// THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <unistd.h>
#include <time.h>
#include <sys/times.h>
#include <sys/types.h>

#define DIFF_SMALL_MSG "*** no time diff"

#define KB (1024LL)
#define MB (KB * KB)

void fatal (const char *format, ...) {
va_list args;

   fflush (stdout);
   va_start (args, format);
   vfprintf (stderr, format, args);
   fprintf (stderr, "\n");
   va_end (args);
   exit (-1);
}

char *cvtsze (u_long s) {
double ds = s;
int i = 0;
static char b [64];

   if (ds >= KB) {
      ds /= KB;
      i++;
      if (ds >= KB) {
         ds /= KB;
         i++;
      }
   }
   sprintf (b, "%5.2f ", ds);

   switch (i) {
      case 1:
         strcat (b, "K");
         break;
      case 2:
         strcat (b, "M");
   }
   return b;
}

u_long test_beg = 300 * MB;         // start from
u_long test_end = 400 * MB;         // test to
u_long test_step = 10 * MB;         // test step
u_long test_lups = 2;            // test loops

int main (int argc, char *argv []) {
u_long size, i, j;
register u_long d;
volatile u_long *mem;
struct tms tms;
time_t start, stop, diff;
long long rdiff, wdiff, total;
int oc;

   // parses the command line.
   while ((oc = getopt (argc, argv, "f:t:s:l:?")) != -1) switch (oc) {
      case 'f':
         test_beg = atol (optarg) * MB;
         break;

      case 't':
         test_end = atol (optarg) * MB;
         break;

      case 's':
         test_step = atol (optarg) * MB;
         break;

      case 'l':
         test_lups = atol (optarg);
         break;

      case '?':
      default:
         fatal ("usage: %s "
               "[-f <from mb>] "
               "[-t <to mb>] "
               "[-s <step mb>]"
               "[-l <loops>]",
                  argv [0]);
   }
   argc -= optind;
   argv += optind;

   if (test_beg < 1)
      fatal ("invalid starting size.");
   if (test_end < test_beg)
      fatal ("invalid ending size.");
   if ((test_step < 1) || (test_step > (test_end - test_beg)))
      fatal ("invalid step size.");
   if (test_lups < 1)
      fatal ("invalid number of loops.");

   printf ("%10s: %15sB\n", "start from", cvtsze (test_beg));
   printf ("%10s: %15sB\n", "test to", cvtsze (test_end));
   printf ("%10s: %15sB\n", "step", cvtsze (test_step));
   printf ("%10s: %14s\n", "loops", cvtsze (test_lups));

   mem = malloc (test_end);
   if (! mem) fatal ("malloc() failed to alloc %sB", cvtsze (test_end));

   printf ("\n" "mapping memory... ");
   fflush (stdout);
   memset ((void *) mem, 0, test_end);
   printf ("done.\n");

   printf ("\n" "%21s " "%23s" "%23s" "\n",
      "size", "write speed", "read speed");

   total = rdiff = wdiff = 0;
   for (size = test_beg; size <= test_end; size += test_step) {

      printf ("%20sB ", cvtsze (size));
      fflush (stdout);

      times (& tms);
      start = tms. tms_utime;
      for (i = 0; i < test_lups; i++) {
         for (j = 0; j < size / sizeof (u_long); j += 64) {
            mem [j + 0x0] = 0;
            mem [j + 0x1] = 0;
            mem [j + 0x2] = 0;
            mem [j + 0x3] = 0;
            mem [j + 0x4] = 0;
            mem [j + 0x5] = 0;
            mem [j + 0x6] = 0;
            mem [j + 0x7] = 0;
            mem [j + 0x8] = 0;
            mem [j + 0x9] = 0;
            mem [j + 0xa] = 0;
            mem [j + 0xb] = 0;
            mem [j + 0xc] = 0;
            mem [j + 0xd] = 0;
            mem [j + 0xe] = 0;
            mem [j + 0xf] = 0;

            mem [j + 0x10] = 0;
            mem [j + 0x11] = 0;
            mem [j + 0x12] = 0;
            mem [j + 0x13] = 0;
            mem [j + 0x14] = 0;
            mem [j + 0x15] = 0;
            mem [j + 0x16] = 0;
            mem [j + 0x17] = 0;
            mem [j + 0x18] = 0;
            mem [j + 0x19] = 0;
            mem [j + 0x1a] = 0;
            mem [j + 0x1b] = 0;
            mem [j + 0x1c] = 0;
            mem [j + 0x1d] = 0;
            mem [j + 0x1e] = 0;
            mem [j + 0x1f] = 0;

            mem [j + 0x20] = 0;
            mem [j + 0x21] = 0;
            mem [j + 0x22] = 0;
            mem [j + 0x23] = 0;
            mem [j + 0x24] = 0;
            mem [j + 0x25] = 0;
            mem [j + 0x26] = 0;
            mem [j + 0x27] = 0;
            mem [j + 0x28] = 0;
            mem [j + 0x29] = 0;
            mem [j + 0x2a] = 0;
            mem [j + 0x2b] = 0;
            mem [j + 0x2c] = 0;
            mem [j + 0x2d] = 0;
            mem [j + 0x2e] = 0;
            mem [j + 0x2f] = 0;

            mem [j + 0x30] = 0;
            mem [j + 0x31] = 0;
            mem [j + 0x32] = 0;
            mem [j + 0x33] = 0;
            mem [j + 0x34] = 0;
            mem [j + 0x35] = 0;
            mem [j + 0x36] = 0;
            mem [j + 0x37] = 0;
            mem [j + 0x38] = 0;
            mem [j + 0x39] = 0;
            mem [j + 0x3a] = 0;
            mem [j + 0x3b] = 0;
            mem [j + 0x3c] = 0;
            mem [j + 0x3d] = 0;
            mem [j + 0x3e] = 0;
            mem [j + 0x3f] = 0;

         }
      }

      times (& tms);
      stop = tms. tms_utime;
      diff = stop - start;
      wdiff += diff;

      if (diff)
         printf ("%20sB/s",
            cvtsze (size / diff * CLK_TCK * test_lups));
      else
         printf ("%23s", DIFF_SMALL_MSG);
      fflush (stdout);

      times (& tms);
      start = tms. tms_utime;
      for (i = 0; i < test_lups; i++) {
         for (j = 0; j < size / sizeof (u_long); j += 64) {
            d = mem [j + 0x0];
            d = mem [j + 0x1];
            d = mem [j + 0x2];
            d = mem [j + 0x3];
            d = mem [j + 0x4];
            d = mem [j + 0x5];
            d = mem [j + 0x6];
            d = mem [j + 0x7];
            d = mem [j + 0x8];
            d = mem [j + 0x9];
            d = mem [j + 0xa];
            d = mem [j + 0xb];
            d = mem [j + 0xc];
            d = mem [j + 0xd];
            d = mem [j + 0xe];
            d = mem [j + 0xf];

            d = mem [j + 0x10];
            d = mem [j + 0x11];
            d = mem [j + 0x12];
            d = mem [j + 0x13];
            d = mem [j + 0x14];
            d = mem [j + 0x15];
            d = mem [j + 0x16];
            d = mem [j + 0x17];
            d = mem [j + 0x18];
            d = mem [j + 0x19];
            d = mem [j + 0x1a];
            d = mem [j + 0x1b];
            d = mem [j + 0x1c];
            d = mem [j + 0x1d];
            d = mem [j + 0x1e];
            d = mem [j + 0x1f];

            d = mem [j + 0x20];
            d = mem [j + 0x21];
            d = mem [j + 0x22];
            d = mem [j + 0x23];
            d = mem [j + 0x24];
            d = mem [j + 0x25];
            d = mem [j + 0x26];
            d = mem [j + 0x27];
            d = mem [j + 0x28];
            d = mem [j + 0x29];
            d = mem [j + 0x2a];
            d = mem [j + 0x2b];
            d = mem [j + 0x2c];
            d = mem [j + 0x2d];
            d = mem [j + 0x2e];
            d = mem [j + 0x2f];

            d = mem [j + 0x30];
            d = mem [j + 0x31];
            d = mem [j + 0x32];
            d = mem [j + 0x33];
            d = mem [j + 0x34];
            d = mem [j + 0x35];
            d = mem [j + 0x36];
            d = mem [j + 0x37];
            d = mem [j + 0x38];
            d = mem [j + 0x39];
            d = mem [j + 0x3a];
            d = mem [j + 0x3b];
            d = mem [j + 0x3c];
            d = mem [j + 0x3d];
            d = mem [j + 0x3e];
            d = mem [j + 0x3f];

         }
      }

      times (& tms);
      stop = tms. tms_utime;
      diff = stop - start;
      rdiff += diff;

      if (diff)
         printf ("%20sB/s",
            cvtsze (size / diff * CLK_TCK * test_lups));
      else
         printf ("%23s", DIFF_SMALL_MSG);

      printf ("\n");
      total += size;
   }

   printf ("\n" "%21s ", "average");

   if (wdiff)
      printf ("%20sB/s",
         cvtsze (total / wdiff * CLK_TCK * test_lups));
   else
      printf ("%23s", DIFF_SMALL_MSG);

   if (rdiff)
      printf ("%20sB/s",
         cvtsze (total / rdiff * CLK_TCK * test_lups));
   else
      printf ("%23s", DIFF_SMALL_MSG);

   printf ("\n");

   return 0;
}


ето ти резултати за две примерни системи:

еднопроцесорна машина с pentium4 на 3GHz с hyperthreading:
Примерен код

./memspeed > result.danov.txt
start from:        300.00 MB
   test to:        400.00 MB
      step:         10.00 MB
     loops:          2.00

mapping memory... done.

                 size             write speed             read speed
            300.00 MB            1132.08 MB/s           2307.69 MB/s
            310.00 MB            1127.27 MB/s           2296.30 MB/s
            320.00 MB            1122.81 MB/s           2285.71 MB/s
            330.00 MB            1118.64 MB/s           2275.86 MB/s
            340.00 MB            1114.75 MB/s           2266.67 MB/s
            350.00 MB            1111.11 MB/s           2333.33 MB/s
            360.00 MB            1107.69 MB/s           2322.58 MB/s
            370.00 MB            1104.48 MB/s           2387.10 MB/s
            380.00 MB            1101.45 MB/s           2303.03 MB/s
            390.00 MB            1098.59 MB/s           2294.12 MB/s
            400.00 MB            1111.11 MB/s           2285.71 MB/s

              average            1112.72 MB/s           2305.39 MB/s

cat /proc/cpuinfo >> result.danov.txt
processor   : 0
vendor_id   : GenuineIntel
cpu family   : 15
model      : 2
model name   : Intel(R) Pentium(R) 4 CPU 3.00GHz
stepping   : 9
cpu MHz      : 2992.553
cache size   : 512 KB
fdiv_bug   : no
hlt_bug      : no
f00f_bug   : no
coma_bug   : no
fpu      : yes
fpu_exception   : yes
cpuid level   : 2
wp      : yes
flags      : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe cid
bogomips   : 5976.88

processor   : 1
vendor_id   : GenuineIntel
cpu family   : 15
model      : 2
model name   : Intel(R) Pentium(R) 4 CPU 3.00GHz
stepping   : 9
cpu MHz      : 2992.553
cache size   : 512 KB
fdiv_bug   : no
hlt_bug      : no
f00f_bug   : no
coma_bug   : no
fpu      : yes
fpu_exception   : yes
cpuid level   : 2
wp      : yes
flags      : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe cid
bogomips   : 5976.88

cat /proc/meminfo >> result.danov.txt
        total:    used:    free:  shared: buffers:  cached:
Mem:  494342144  8257536 486084608        0   335872  3215360
Swap:        0        0        0
MemTotal:       482756 kB
MemFree:        474692 kB
MemShared:           0 kB
Buffers:           328 kB
Cached:           3140 kB
SwapCached:          0 kB
Active:           2276 kB
Inactive:         1480 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:       482756 kB
LowFree:        474692 kB
SwapTotal:           0 kB
SwapFree:            0 kB
двупроцесорна машина с xeon на 2.8GHz с hyperthreading:
Примерен код
./memspeed > result.pluto.txt
start from:        300.00 MB
   test to:        400.00 MB
      step:         10.00 MB
     loops:          2.00

mapping memory... done.

                 size             write speed             read speed
            300.00 MB             714.29 MB/s           1818.18 MB/s
            310.00 MB             720.93 MB/s           1823.53 MB/s
            320.00 MB             711.11 MB/s           1828.57 MB/s
            330.00 MB             709.68 MB/s           1833.33 MB/s
            340.00 MB             715.79 MB/s           1789.47 MB/s
            350.00 MB             714.29 MB/s           1842.11 MB/s
            360.00 MB             712.87 MB/s           1846.15 MB/s
            370.00 MB             711.54 MB/s           1804.88 MB/s
            380.00 MB             716.98 MB/s           1809.52 MB/s
            390.00 MB             715.60 MB/s           1813.95 MB/s
            400.00 MB             714.29 MB/s           1818.18 MB/s

              average             714.29 MB/s           1820.33 MB/s

cat /proc/cpuinfo >> result.pluto.txt
processor   : 0
vendor_id   : GenuineIntel
cpu family   : 15
model      : 2
model name   : Intel(R) Xeon(TM) CPU 2.80GHz
stepping   : 5
cpu MHz      : 2791.045
cache size   : 512 KB
fdiv_bug   : no
hlt_bug      : no
f00f_bug   : no
coma_bug   : no
fpu      : yes
fpu_exception   : yes
cpuid level   : 2
wp      : yes
flags      : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm
bogomips   : 5570.56

processor   : 1
vendor_id   : GenuineIntel
cpu family   : 15
model      : 2
model name   : Intel(R) Xeon(TM) CPU 2.80GHz
stepping   : 5
cpu MHz      : 2791.045
cache size   : 512 KB
fdiv_bug   : no
hlt_bug      : no
f00f_bug   : no
coma_bug   : no
fpu      : yes
fpu_exception   : yes
cpuid level   : 2
wp      : yes
flags      : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm
bogomips   : 5570.56

processor   : 2
vendor_id   : GenuineIntel
cpu family   : 15
model      : 2
model name   : Intel(R) Xeon(TM) CPU 2.80GHz
stepping   : 5
cpu MHz      : 2791.045
cache size   : 512 KB
fdiv_bug   : no
hlt_bug      : no
f00f_bug   : no
coma_bug   : no
fpu      : yes
fpu_exception   : yes
cpuid level   : 2
wp      : yes
flags      : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm
bogomips   : 5570.56

processor   : 3
vendor_id   : GenuineIntel
cpu family   : 15
model      : 2
model name   : Intel(R) Xeon(TM) CPU 2.80GHz
stepping   : 5
cpu MHz      : 2791.045
cache size   : 512 KB
fdiv_bug   : no
hlt_bug      : no
f00f_bug   : no
coma_bug   : no
fpu      : yes
fpu_exception   : yes
cpuid level   : 2
wp      : yes
flags      : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm
bogomips   : 5570.56

cat /proc/meminfo >> result.pluto.txt
        total:    used:    free:  shared: buffers:  cached:
Mem:  2119323648 87310336 2032013312        0  5816320 40476672
Swap:        0        0        0
MemTotal:      2069652 kB
MemFree:       1984388 kB
MemShared:           0 kB
Buffers:          5680 kB
Cached:          39528 kB
SwapCached:          0 kB
Active:          20208 kB
Inactive:        29096 kB
HighTotal:     1179584 kB
HighFree:      1135828 kB
LowTotal:       890068 kB
LowFree:        848560 kB
SwapTotal:           0 kB
SwapFree:            0 kB


за изчисленията не мога да ти дам добър съвет. лично аз ползвам стандартния dhrystone, обаче той дава само груба представа за производителността на професора и изобщо не замерва floating point-a. пробвай да питаш чичко google.

ред. ivak 15-11-05 12:46 - съжалявам, copy-paste разформатира текста на програмата, но все още може да се компилира.
Активен

Cлoжнитe пpoблeми имaт пpocти и лecни зa paзбиpaнe гpeшни oтгoвopи.

Yasen6275

  • Напреднали
  • *****
  • Публикации: 553
    • Профил
Мерси за програмката. Може ли един бърз курс по компилиране за начинаещи?
Активен

zeridon

  • Killmode enabled
  • Administrator
  • Напреднали
  • *****
  • Публикации: 1398
  • Distribution: Debian/Ubuntu
  • Window Manager: console/Gnome
  • BOfH
    • Профил
    • WWW
cc sors.c -o executable
Активен

Внмимавай имам клещи за кабел
http://www.netsecad.com/
http://theregister.co.uk/odds/bofh/

ivak

  • Напреднали
  • *****
  • Публикации: 156
    • Профил
пропуснах още нещо: когато тестваш някоя подсистема, гледай да няма много работещи процеси. най-добре пусни системата в single mode без графична среда.
Активен

Cлoжнитe пpoблeми имaт пpocти и лecни зa paзбиpaнe гpeшни oтгoвopи.

Yasen6275

  • Напреднали
  • *****
  • Публикации: 553
    • Профил
А как става това за FC4 и Gentoo?

Извинявам се за тъпите въпроси.
Активен

  • Гост
Цитат (Yasen6275 @ Ноември 16 2005,18:20)
А как става това за FC4 и Gentoo?

Извинявам се за тъпите въпроси.

виж init(8)
Активен

ivak

  • Напреднали
  • *****
  • Публикации: 156
    • Профил
Цитат (Yasen6275 @ Ноември 16 2005,18:20)
А как става това за FC4 и Gentoo?

Извинявам се за тъпите въпроси.

обикновено става с командата:
Примерен код
telinit S
Ако това не проработи (което се случва, ако са криви системните скриптове; не знам какъв е случаят с gentoo), рестартирай и напиши на LILO промпта:
Примерен код
<кернел> init=/bin/bash
Замени <кернел> със съответното име на кернела, който ползваш. Този метод работи винаги, и между другото е за предпочитане, защото при него получаваш система само с един потребителски процес - bash. Имай предвид, че в този случай дисковете остават в read-only режим.
Активен

Cлoжнитe пpoблeми имaт пpocти и лecни зa paзбиpaнe гpeшни oтгoвopи.

Yasen6275

  • Напреднали
  • *****
  • Публикации: 553
    • Профил
Благодаря на всички за скоростното отзоваване.
Активен