Hi Experts,
I try to create 600 SUComponentDefinitionRef and add it into the model. I find that the following Way 1(~10s) has the better performance than Way 2(~34s) when add 600 SUComponentDefinitionRef into the model. Is it expected? From my initial expectation, I think that Way 2 should have the better performance than Way1.
Also, I want to know whether it is expected that creating 600 SUComponentDefinitionRef and adding it into the model will cost ~10s.
Way 1:
clock_t init, final;
init = clock();
int compsize = 600;
for (int i = 0 ; i < compsize; ++i)
{
SUComponentDefinitionRef SUCompDef = SU_INVALID;
SUComponentDefinitionCreate(&SUCompDef);
SUModelAddComponentDefinitions(SUModel, 1, &SUCompDef);
}
final = clock() - init;
std::cout <<"Translation time1: " << (double)final / ((double)CLOCKS_PER_SEC) << "s" << std::endl;
Way 2:
SUComponentDefinitionRef* pSiComp = new SUComponentDefinitionRef[compsize];
for (int i = 0 ; i < compsize; ++i)
{
SUComponentDefinitionRef SUCompDef = SU_INVALID;
SUComponentDefinitionCreate(&SUCompDef);
pSiComp[i] = SUCompDef;
}
clock_t init2, final2;
init2 = clock();
SUModelAddComponentDefinitions(SUModel, compsize, pSiComp);
final2 = clock() - init2;
std::cout <<"Translation time2: " << (double)final2 / ((double)CLOCKS_PER_SEC) << "s" << std::endl;
delete [] pSiComp;