Results 1 to 8 of 8

Thread: Speed up?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Posts
    367

    Speed up?

    Anyone see a way to speed this function up??

    Code:
    void MpEvent(UINT32 eventID, UINT32 buffer)
    {
        int l;
        UINT32 *row;
        if(mlb.logBuffer != NULL)
        {
            row = mlb.logBuffer[mlb.numEvent];
            row[0] = HWCLK32BIT;
            row[1] = SWCLK32BIT;
            row[2] = eventID;
            row[3] = buffer;
            ++mlb.numEvent;
            /* check to see if the end of the log buffer was reached */
            if(mlb.numEvent >= mlb.maxEvents) 
            {
                mlb.looped = TRUE;
                mlb.numEvent = 0;
            }
        }
        else 
        {
            /* We should never get here because the only way to free the log buffer 
            * is by calling MpLogFree, which turns logging off as well */
            printf("There is no buffer allocated for main path event logging\n");
        }
    
    }
    Any help appreciated...
    Thanks
    Bill

  2. #2
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Is it that slow than?
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Posts
    367

    Wink

    no it really isnt too slow, but all the more faster is better...

    I am thinking of putting that whole function into assembly. The compiler is not very efficent, keeps recalculating the address of mlb.numEvent, when it really only needs to do it once and store that in a register, dumb thing. so that should give me a performance boost of sorts.

  4. #4
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Maybe it'll be a bit faster if you replace
    PHP Code:

            
    if(mlb.numEvent >= mlb.maxEvents
            {
                
    mlb.looped TRUE;
                
    mlb.numEvent 0;
            } 
    with
    PHP Code:

            mlb
    .numEvent >= mlb.maxEvents ?  mlb.looped TRUE :     mlb.numEvent 0
    Baaaaaaaaah

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Posts
    367
    Sorry that wouldn't work, the ? and : is a "if a then b else x"
    not a "if a then b and c"

  6. #6
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Oh never mind...
    Baaaaaaaaah

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Posts
    367
    not a problem,
    a wrong solution is not a bad idea, just another solution that shows what doesn't work

  8. #8
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    I think the only thing you can do to speed this up is getting a better compiler.

    Maybe this is a little bit faster:
    instead of
    Code:
            row[0] = HWCLK32BIT;
            row[1] = SWCLK32BIT;
            row[2] = eventID;
            row[3] = buffer;
    do
    Code:
            *row = HWCLK32BIT;
            ++row;
            *row = SWCLK32BIT;
            ++row;
            *row = eventID;
            ++row;
            *row = buffer;
    But you'd have to check that. The 386 supports direct indexing which is supposed to be very fast, but you can never be sure.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width