Category Archives: My Thoughts

Benchmark Generation 2 i5 -vs- Generation 3 i5

Once and a while I will benchmark a PC that I happen to get my hands on. I tested a laptop with a Gen 3 i5 and compared it to my desktop with has 2 Gen 2 i5….

erick@OptiPlex-790 ~/factor $ tail i5-3340M@3200Mhz-bmark.txt

Calculations Completed!
 Time: 9 seconds

Factor: Finished in about 10.000000 seconds.
 Pi: Finished in about 9.000000 seconds.

Factor to Pi Ratio 1.111111
 erick@OptiPlex-790 ~/factor $ tail i5-2500@3700.txt

Calculations Completed!
 Time: 9 seconds

Factor: Finished in about 10.000000 seconds.
 Pi: Finished in about 9.000000 seconds.

Factor to Pi Ratio 1.111111

It looks like a Generation 2 i5 running at 3700MHz can run calculations at the same rate as a Generation 3 i5 at 3200MHz. The benchmark is both a pi calculation and a factoring calculation. The ratios will vary from processor to processor sometimes. Especially across old -vs- new ones. But these seem to line up.

Comparison

It looks like the raw speed difference for a given clock speed, 3700/3200 = 1.15625x faster. In other words, the Gen 2 has to be running 1.15625x faster on the clock to get the same speeds.

Note: The MHz values are running one core at turbo speed.

Code

The code is something that I patched together. I wrote the factoring part years ago to run under MS-DOS and ported it to compile under GCC. I made it at a time that I was toying around with extracting factors of numbers and was an exercise in making speed efficient code. I always had some spare moments while waiting for other compiles to happen. At the time I was working on embedded code in industry, these compiles could take a few minutes with each change and up to 20 minutes when doing a scratch build. This is on machines of the Pentium 2 -4 era. When writing embedded code and compiling there were plenty of slices of time to experiment with other code.

The Pi part I snagged off the web a long time ago, not sure where, or I would reference it here. It is interesting to see how the speeds will vary between the Pi and Factor parts, therefore I compute a ratio of them. I fiddled with the constants so that the time that both parts run is about 10 seconds and around a 1:1 ratio on my current desktop i5@3300Mhz. Essentially the desktop is the reference normal against which I am comparing other machines.

 

 

#include <stdio.h> 
#include <float.h> 
#include <time.h> 
#include <stdlib.h> 
#include <sys/time.h> 
#include <unistd.h> 
 
 
    unsigned int x; 
unsigned int f = 0, stopn = 100000, maxFactor = 0; //4294967295 
   time_t curtime; 
 
     
    FILE *fp; 
 
 
long secstart, usecstart; 
long kf, ks; 
long *mf, *ms; 
long cnt, n, temp, nd; 
long i; 
long col, col1; 
long loc, stor[40]; 
 
int main(void) 
{ 
 
  float factor_time; 
  float pi_time; 
  float ratio; 
  factor_time = factor(); 
  pi_time = pi(); 
 
  ratio = factor_time / pi_time; 
   printf("\n\nFactor: Finished in about %f seconds. \n", factor_time); 
   printf("Pi: Finished in about %f seconds. \n", pi_time); 
 
   printf("\n\nFactor to Pi Ratio %f \n",ratio ); 
 
} 
 
 
int factor(void) 
{ 
    unsigned int i = 1; 
    unsigned int n; 
 
    time_t start, stop; 
    clock_t ticks; long count; 
 
     
    //scanf("%s",fname); 
    //scanf("%i",stopn); 
    //fopen("temp.txt","w"); 
    //stopn = argv[i]; 
 
 
    // Mark off the start time for the program.  
   time(&start); 
 
    for(n = 1;n < stopn;n++) 
    { 
        
    #if 1 
      // Inner loop, Walk through all values of numbers up to 1 more than the middle number. 
        for(x = 2;x < (n/2)+1;x++) 
        { 
          // Found a factor incriment f 
      //      if((n/x) - (int)(n/x) == 0) 
      if(n%x == 0) 
            { 
                f++; 
            } 
        } 
    #endif 
 
        //fprintf(fp,"%i    %i \n",n,f); 
    // If the value of the factor f is larger than the largest factor found, mark the occurance. 
    if(f > maxFactor) 
    { 
      printf("%i\t %i\t",n,f); 
 
      maxFactor = f; 
 
      // Get Current Time, print it out. 
      time(&curtime); 
      printf("%s", ctime(&curtime)); 
 
    } 
        // Reset the factor count for the next outer loop. 
        f = 0; 
        
    } 
 
    // Mark the stop time of the program. 
 
   time(&stop); 
    
   // How long did the program run and how much CPU time did it use. 
   //   printf("Used %0.2f seconds of CPU time. \n", (double)ticks/CLOCKS_PER_SEC); 
   printf("Finished in about %.0f seconds. \n", difftime(stop, start)); 
 
    return(difftime(stop, start)); 
} 
 
 
 
 
 
 
 
 
 
 
void shift(long *l1, long *l2, long lp, long lmod) 
{ 
    long k; 
 
    k = ((*l2) > 0 ? (*l2) / lmod: -(-(*l2) / lmod) - 1); 
    *l2 -= k * lmod; 
    *l1 += k * lp; 
} 
 
void yprint(long m) 
{ 
    if (cnt<n) 
    { 
        if (++col == 11) 
        { 
            col = 1; 
            if (++col1 == 6) 
                { 
                    col1 = 0; 
                    printf("\n"); 
                    printf("%4ld",m%10); 
                } 
            else printf("%3ld",m%10); 
        } 
        else printf("%ld",m); 
        cnt++; 
    } 
} 
 
void xprint(long m) 
{ 
    long ii, wk, wk1; 
 
    if (m < 8) 
    { 
        for (ii = 1; ii <= loc; ) 
        yprint(stor[(int)(ii++)]); 
        loc = 0; 
    } 
    else 
    { 
        if (m > 9) 
        { 
            wk = m / 10; 
            m %= 10; 
            for (wk1 = loc; wk1 >= 1; wk1--) 
            { 
                wk += stor[(int)wk1]; 
                stor[(int)wk1] = wk % 10; 
                wk /= 10; 
            } 
        } 
    } 
    stor[(int)(++loc)] = m; 
} 
 
void memerr(int errno) 
{ 
    printf("\a\nOut of memory error #%d\n", errno); 
    if (2 == errno) 
    free(mf); 
    _exit(2); 
} 
 
int pi(void) 
{ 
    int i=0; 
    char *endp; 
 
 
    stor[i++] = 0; 
 
    n = 22000; 
 
    mf = malloc((size_t)(n + 3L)*(size_t)sizeof(long)); 
    if (!mf) 
    memerr(1); 
    ms = malloc((size_t)(n + 3L)*(size_t)sizeof(long)); 
    if (!ms) 
    memerr(2); 
    printf("\nApproximation of PI to %ld digits\n", (long)n); 
 
    struct timeval tv; 
    struct timezone tz; 
        gettimeofday(&tv, &tz); 
        secstart=tv.tv_sec; 
        usecstart=tv.tv_usec; 
    cnt = 0; 
    kf = 25; 
    ks = 57121L; 
    mf[1] = 1L; 
    for (i = 2; i <= (int)n; i += 2) 
    { 
        mf[i] = -16L; 
        mf[i+1] = 16L; 
    } 
    for (i = 1; i <= (int)n; i += 2) 
    { 
        ms[i] = -4L; 
        ms[i+1] = 4L; 
    } 
    printf("\n 3."); 
    while (cnt < n) 
    { 
        for (i = 0; ++i <= (int)n - (int)cnt; ) 
        { 
            mf[i] *= 10L; 
            ms[i] *= 10L; 
        } 
        for (i =(int)(n - cnt + 1); --i >= 2; ) 
        { 
            temp = 2 * i - 1; 
            shift(&mf[i - 1], &mf[i], temp - 2, temp * kf); 
            shift(&ms[i - 1], &ms[i], temp - 2, temp * ks); 
        } 
        nd = 0; 
        shift((long *)&nd, &mf[1], 1L, 5L); 
        shift((long *)&nd, &ms[1], 1L, 239L); 
        xprint(nd); 
    } 
    printf("\n\nCalculations Completed!\n"); 
    gettimeofday(&tv, &tz); 
    printf("Time: %ld seconds\n",tv.tv_sec-secstart); 
    free(ms); 
    free(mf); 
    return(tv.tv_sec-secstart); 
}
Pentium 3 without holder and Pentium 4 chip

A look at a Pentium 3 at 500MHz and Pentium 4 at 3.0GHz

Recently I gutted a few old PC’s. The physical difference between the Pentium 3 (P3) from 1999 and Pentium 4 (P4) from 2005 were stark. It made me think of the way computers have progressed in terms of performance and power usage.

Pentium 3

The Pentium 3 that I removed uses a Slot 1 connector. basically it sits on a board that gets inserted into a slot on the motherboard. The little daughter board reveals a bunch of support hardware once the black cover is removed. There are a couple of chips that look like they might be for the RAM Cache. Looking this up in Wikipedia confirms this thought, “The L2 cache is off-die and runs at 50% CPU speed.” It also states a TDP of 28W. No wonder it can get away with a small fan and heatsink.

https://en.wikipedia.org/wiki/List_of_Intel_Pentium_III_microprocessors#.22Katmai.22_.28250_nm.29

Back of Pentium 3 and 4
Back of Pentium 3 and 4

Pentium 4

On the other hand the P4 HT 630 is a LGA 775 type of socket, a bunch of balls on the bottom that make contact to the socket on the motherboard, 475 of them! This socket design was one of the last for the P4. The P4 is a Prescott 2M and has a TDP of 84W. Hence the big fan and heat sink.

https://en.wikipedia.org/wiki/List_of_Intel_Pentium_4_microprocessors

In contrast, a few years ahead in 2009, a more modern computer, with more processing power would have a processor that uses about 40-50W TDP. So heat-sinks and fans have gotten smaller. Along with the power supplies, I had a Dual Xeon Circa 2004 that had a 1000W power supply, it was fast for it’s time, but also a space heater when it was running hard.

Simple Benchmarks

Running a Pi Benchmark written in C, out to 256000 digits. Lower is better.

1999: Old P3 at 700 MHz Time: 13026 seconds TDP about 28W

2004: P4 at 2400 MHz Time: 3741 seconds TDP 84W

2009: Intel(R) Celeron(R) M CPU 520 @ 1.60GHz Time: 2747 seconds TDP 30W

2011: Intel(R) Core(TM) i3-2100 CPU @ 3.10GHz  Time: 986 seconds TDP 65W

 

P3 and P4 Heatsinks
P3 (left) and P4 (right) Heatsinks
P3 fan center, on top of P4 fan
P3 fan center, on top of P4 fan

 

 

Stay relaxed and success will follow

The Bill Murray quote on site is a good one, really makes you think. The site is great, lots of useful content about Linux and the Raspberry Pi, plus OpenWRT router mods. I have learned a lot ( and used it ) by skimming through his posts. He also has some interesting quotes like the Bill Murray one below.

Bill Murray on staying relaxed and how success will follow:

http://www.circuidipity.com/20140918.html

 

 


 

A mom and her son watch the mushroom cloud after an atomic test 75 miles away, Las Vegas , 1953.

A mom and her son watch the mushroom cloud after an atomic test 75 miles away, Las Vegas , 1953.
A mom and her son watch the mushroom cloud after
an atomic test 75 miles away, Las Vegas , 1953.

 

 

I’d love to have seen a nuke go off, from a safe distance of course. The scientist Richard Feynman was the only one at the Trinity test to view it in full glory without eye shielding. He figured sitting in a car the glass would not let the dangerous UV rays pass though, which is true. I read about this in the great book The Making of the Atomic Bomb, about the Manhattan Project by Richard Rhodes. Speaking of good books about Richard Feynman’s adventures, Tuva or Bust by Ralph Leighton. It is one of the best books I have read out of the hundreds I have read.

Now that there is no more above ground testing. The best I can do is visit the  National Museum of Nuclear Science & History in Albuquerque, NM and the Bradbury Science Museum a window into the Los Alamos National Laboratory in NM. The Bradbury Musuem was seen in one of the early episodes of Breaking Bad as a meet up spot. After these museums, it would only be appropriate to drive up to Santa Fe and visit art museums as well, being just a short drive away. Someday I will make it to beautiful New Mexico and see the sights.

Richard Feynman TED talk

TED has a series of videos that feature Richard Feynman. In these videos he takes normal everyday things that we take for granted and explores them using science to bring out aspects that we may not have thought of. He does it in a way that makes it understandable for anyone. This talk is a stitched together series of short video interviews that essential is a posthumous TED talk featuring Richard Feynman.

Richard Feynman TED talk

Atomic Art

As an aside, I have actually done art that features an atomic bomb. This is why I would be interested in both the nuclear museums and the art museums in New Mexico! This piece represents the style of art that I have taken a liking to working in. I start in pencil and sometimes even thickening and darkening the work with pen or marker. Then I scan the piece in and work on the color and detail of bringing in different elements such as the background by using the GIMP editor. Essentially the piece is made up of different parts that are merged together in a final image. The sky, tower and ground were all created independently and merged.

 

Atomic Bomb Test Tower
Atomic Bomb Test Tower

You are NOT a Software Engineer

Below is a link to a great post that is dead on. I used to think about the fact that software engineering doesn’t follow the same work pattern as engineering physical things when I worked in industry. People get the idea that you can schedule software projects when it is more like forecasting. I liken it to the tides versus the weather, you can schedule plans around the tides, years in advance, as there are actual schedules of the tides, a.k.a. Tide Tables,  not so with regard to the weather.
You don’t always know where things will be at a certain point in the future. Predicting things a few days out OK, trying to plan a software project grandiose style 6 months ahead and know where it is going to land, is like trying to make plans around a sunny and 72 degree July 4h BBQ, but trying to figure out that probability in January!

Chris Aitchison, says what I was thinking for years, but much better than I could have put it….

www.chrisaitchison.com/2011/05/03/you-are-not-a-software-engineer/

Sent from my Android phone with K-9 Mail. Please excuse my brevity.

Los Pollos Hermanos

Halloween: Los Pollos Hermanos

Breaking Bad is for me the #1 drama show that I have seen to date. So, for Halloween, I decided to go with a Breaking bad theme. So I dressed  up like a Los Pollos Hermanos worker.

Los Pollos, Special Delivery!
Los Pollos, Special Delivery!
Something Good is always COOKING at Los Pollos Hermanos
Something Good is always COOKING at Los Pollos Hermanos

Made a nice prop, hacked a Hallmark recordable greeting card, 10 seconds of record time and it plays the Breaking Bad theme song, just about fits in the 10 secs. I had to do about 10 takes to hit the timing and audio level. But when the “Los Pollos” takeout box is opened, it plays, works great.

Video of the Box Opening

Video of Box Opening Plays Breaking Bad Theme

Made some Blue Sky “meth” candy to put in the takeout box!

I looked online, the blue stuff was like $12 a pound. I know how to cook for real, don’t bake much but, I should be able to make hard candy! I even found Sky Blue food coloring at a real food supply store.

Sky Blue food coloring
Sky Blue food coloring

I have a video that I learned from at the bottom of this post, it is dead on, except I used more flavoring. After 2 batches, I wanted more flavor, so I threw in a tbsp of almond extract.  Seriously, it is easy, it is a heat, stir wait kind of process. First put water, sugar and corn syrup in the pot, heat slowly until dissolved. Turn up heat raise until approximately 290 F. Kill the heat and add flavor and food coloring,  just before the pour occurs. Pour on wax paper and tilt the pan to spread, beat it to pieces!

Breaking is GOOD in this process!
Breaking is GOOD in this process!
Boils and Boils until it hits around 290 Deg. F
Boils and Boils until it hits around 290 Deg. F
Pouring the product!
Pouring the product!
The ingredients
The ingredients
Smashing the crystal!
Smashing the crystal!

 

The Box Cover

Edited a logo I found on line and tweaked it in the GIMP editor, click on it for full size, feel free to use it…

Los Pollos Box Cover
Los Pollos Box Cover
Breaking Bad Blue Sky Crystal Meth Candy

I followed the following cool and descriptive video to make the goods…

Configuring Posting via email for WordPress

I am testing out the ability to post via a secret email, this is how I created this post, then edited some more in WP.

I fussed with it for a bit, sending emails and expecting results. I didn’t realize that the email reading for WP has to be stroked. So I put together a cron job to stroke the reading of email periodically (daily for the moment, which seems reasonable) via php
using…

php -q /home/yourcpanelusername/path-to-folder/wp-mail.php

Which didn’t work, initially. I kept getting email via cron which has XML in the body, it is an error with a line at the bottom…

<p>Slow down cowboy, no need to check for new mails so often!</p>

Then I tried this

But manually stroking the email by going to the URL where wp-mail.php lives does kick the email to a post as lists it as pending. This in my mind is not terribly useful. I would prefer to send an email and have not be a pending post as I would like to post from email without needing to login to WP, in other words just post it already.

Mysteriously after experimenting with sending a few posts by email, it started to work. I sm not sure why, but checking the mail daily at 1AM, it either gets the messages, creates a pending post and deletes the copies on the mail server as it should and reports this in a CRON email. Or there are no emails for it and it reports that correctly. After an initial weirdness it has been working fine and as expected for several weeks.