The Gstreamer plugin run slow

Hi, I have created a GStreamer plugin. In my plugin, I add a simple test code, as follows:

long long int sum = 0;
for (long long int i=0; i< 1000; i++)
{
    for(int j=0; j< 1000000; j++)
    {
        sum = sum + i + j;
    }

}

when run in single thread in that plug-in, this part takes about 4.01s. when run in double threads, this part need takes about 8.02s.
However if I isolate to run the simple test code, that part is done in only takes about 3.78s.
why?

Please run tegrastats to check CPU loading.

DeepStream SDK requires high loading, and other processes may be affected.

We were only running DeepStream SDK at that time, it didn’t run other processes.

Hi,
Do you follow [Implementing a Custom Plugin] in the document? We have a custom plugin ‘dsexample’. Suggest you implement your usecase in this plugin.

Also if it is an issue in your usecase, please share a practical sample. We would like to check real usecase instead of dummy test code.

I have been test in the custom plugin ‘dsexample’,I add the test code in dsexample_lib.c:

DsExampleOutput *
DsExample_DequeueOutput (DsExampleCtx * ctx)
{
  DsExampleOutput *out = g_malloc0 (sizeof (DsExampleOutput));

  // Processing finished. Dequeue

  long long int sum = 0;
  double startTime;
  double endTime;
  startTime = clock();
  for (long long int i=0; i< 1000; i++)
  {
      for(int j=0; j< 1000000; j++)
      {
          sum = sum + i + j;
      }

  }
  endTime = clock();
  g_print("------%f\n", (endTime-startTime) / CLOCKS_PER_SEC;

  return out;
}

It had the same result, this part takes about 4.01s.

We think the code is dummy and for test only:

for (long long int i=0; i< 1000; i++)
  {
      for(int j=0; j< 1000000; j++)
      {
          sum = sum + i + j;
      }

  }

Please give real usecase.

Hi 940763113,

Have you clarified the cause and got performance improvement?
Any result can be shared?

Thanks