void cdiDebug(int level) { if ( level == 1 || (level & 2) ) CDI_Debug = 1; if ( CDI_Debug ) Message("debug level %d", level); if ( level == 1 || (level & 4) ) memDebug(1); if ( level == 1 || (level & 8) ) fileDebug(1); if ( level == 1 || (level & 16) ) { #if defined (HAVE_LIBCGRIBEX) gribSetDebug(1); #endif #if defined (HAVE_LIBNETCDF) cdfDebug(1); #endif #if defined (HAVE_LIBSERVICE) srvDebug(1); #endif #if defined (HAVE_LIBEXTRA) extDebug(1); #endif #if defined (HAVE_LIBIEG) iegDebug(1); #endif } if ( CDI_Debug ) { cdiPrintDefaults(); cdiPrintDatatypes(); } }
// ajouter un élément dans la file int push(File* file, message *msg) { debug = fopen("file_debug.txt", "a+"); Node *toPush; if ((toPush = (Node *) malloc (sizeof (Node))) == NULL) { fprintf(debug, "Malloc error !\n"); fclose(debug); return -1; } toPush->msg = msg; toPush->suivant = NULL; // Si pas encore d'élément ajouté, init du début if(file->taille == 0) { file->debut = toPush; } else { file->fin->suivant = toPush; } file->fin = toPush; file->taille++; fprintf(debug, "Pushed in queue : %s\n", toPush->msg->message); fclose(debug); fileDebug(file); return 0; }
void Character::testAnimationSearch(float pNorm, UINT miniHashFunctionCount, UINT macroTableCount) { cout << "Testing LSH " << pNorm << ", " << miniHashFunctionCount << ", " << macroTableCount << endl; LSHEuclidean<CharacterInstance*> search; search.init(animationPCADimension, pNorm, miniHashFunctionCount, macroTableCount); for (auto &instance : allInstances) search.insert(instance.second.reducedAnimationDescriptor, &instance.second); const UINT testInstanceCount = 500; const float targetDistSq = 10.0f; size_t missedSamples = 0; size_t wastedSamples = 0; size_t totalValidSamples = 0; ofstream fileDebug("debug.txt"); for (int test = 0; test < testInstanceCount; test++) { const CharacterInstance &randomInstance = *util::randomElement(allInstancesVec); auto results = search.findSimilar(randomInstance.reducedAnimationDescriptor); for (CharacterInstance *candidate : results) { const float distSq = math::distSq(candidate->reducedAnimationDescriptor, randomInstance.reducedAnimationDescriptor); if (distSq > targetDistSq) wastedSamples++; } for (auto &instance : allInstancesVec) { const float distSq = math::distSq(instance->reducedAnimationDescriptor, randomInstance.reducedAnimationDescriptor); if (test == 0) fileDebug << distSq << endl; if (distSq < targetDistSq) { if (results.count(instance) == 0) missedSamples++; totalValidSamples++; } } } const string filename = "logs/animationSearchTest.txt"; bool emitHeader = !util::fileExists(filename); ofstream file(filename, ios::app); if (emitHeader) { file << "pNorm\tminiHashCount\tmacroTableCount\ttargetDistSq\tavg valid count\tavg missed samples\tavg wasted samples" << endl; } file << pNorm << '\t' << miniHashFunctionCount << '\t' << macroTableCount << '\t' << targetDistSq << '\t'; file << (double)totalValidSamples / (double)testInstanceCount << '\t'; file << (double)missedSamples / (double)testInstanceCount << '\t'; file << (double)wastedSamples / (double)testInstanceCount << endl; }
Node* getFirstMessage(File* file, char* dest) { debug = fopen("file_debug.txt", "a+"); // On parcourt la file pour chercher le premier message qu'il faudra envoyer à dest Node* current = file->debut; Node* previous = NULL; //fprintf(debug, "Looking for messages for %s (len: %d) :\n", dest, strlen(dest)); while(current != NULL) { if( strncmp(current->msg->dest, dest, strlen(dest)) == 0) { fprintf(debug, "begin pop\n"); // Si on enlève le premier élément, on change le début de file if(previous == NULL) { file->debut = current->suivant; } // Sinon, on raccorde l'élément précédent à l'élément suivant else { previous->suivant = current->suivant; } file->taille--; fprintf(debug, "Found a message for %s, return %s.\n", dest, current->msg->message); fprintf(debug, "end pop\n"); fclose(debug); fileDebug(file); return current; } previous = current; current = current->suivant; } fclose(debug); return NULL; }