Results 1 to 3 of 3

Thread: Working with bits and perfomance issue

  1. #1

    Working with bits and perfomance issue

    Hi,

    I've some performance issues and I'd like your advice.
    I'm working with bits. It works fine but the following code takes about 95% of the computation time.
    First, I have an array of 16 value.

    Code :
    float crown[NB_SECTOR]; // NB_SECTOR = 16

    Then, I fill this array with some values read from a 2D image.
    This should take a while. Let's say that at this point, crown is filled.
    Then, I have a descriptor (16bits) that I pack into an integer.
    I set the bit of this descriptor relatively to the values of crown compared to a threshold :

    Code :
    int descriptor = 0;
    for (int i=0; i<NB_SECTOR; ++i) {
        if (crown[i]>threshold){
            descriptor |= (1<<i);
        }
    }

    As I said, this code takes 830 micro-seconds on the total 900 micro-seconds of the computation time.
    How can this code be that long? Filling crown seems to me much more inefficient.

    Thanks,

    Vincent

  2. #2

    Re: Working with bits and perfomance issue

    It seems that the problem comes from the reading of crown.
    Indeed, if I change
    Code :
    int descriptor = 0;
    for (int i=0; i<NB_SECTOR; ++i) {
        if (crown[i]>threshold){
            descriptor |= (1<<i);
        }
    }
    by
    Code :
    int descriptor = 0;
    for (int i=0; i<NB_SECTOR; ++i) {
        if (crown[i]>threshold){
            descriptor++;
        }
    }
    the problem still remains. I continue to investigate.

  3. #3

    Re: Working with bits and perfomance issue

    As usual, it seems that what takes a lot of time is not what I thought it was.
    Le compiler was getting rid of some code when I was commenting other parts.
    Always difficult to understand where the time is used or not...

Similar Threads

  1. Replies: 1
    Last Post: 11-18-2011, 08:13 AM
  2. OpenMAX DL perfomance requirements
    By Rebel in forum OpenMAX DL
    Replies: 1
    Last Post: 03-25-2009, 07:07 AM

Posting Permissions

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