void CacheProfilerState::processCacheItem(CacheProfiler *cp, const s2e::plugins::ExecutionTraceItemHeader &hdr, const s2e::plugins::ExecutionTraceCacheSimEntry &e) { CacheProfiler::Caches::iterator it = cp->m_caches.find(e.cacheId); assert(it != cp->m_caches.end()); Cache *c = (*it).second; assert(c); CacheStatistics addend(e.isWrite ? 0 : e.missCount, e.isWrite ? e.missCount : 0); m_globalStats += addend; #if 0 //Update the per-state global miss-rate count for the cache CacheStatistics &perCache = m_cacheStats[c]; perCache += addend; perCache.c = c; //Update per-instruction misses CacheStats &instrStats = m_perInstructionStats[std::make_pair(hdr.pid, e.pc)]; CacheStatistics &instrPerCache = instrStats[c]; instrPerCache += addend; instrPerCache.c = c; #endif }
static PyObject* pySceneNode_addPoolObjects(pySceneNode* self, PyObject* args) { PyObject* list; if (!PyArg_ParseTuple(args, "O", &list)) { PyErr_SetString(PyExc_TypeError, "addPoolObjects expects a list of plKeys"); return NULL; } if (!PyList_Check(list)) { PyErr_SetString(PyExc_TypeError, "addPoolObjects expects a list of plKeys"); return NULL; } std::vector<plKey> addend(PyList_Size(list)); for (size_t i=0; i<addend.size(); i++) { pyKey* key = (pyKey*)PyList_GetItem(list, i); if (key == NULL) return NULL; if (!pyKey_Check((PyObject*)key)) { PyErr_SetString(PyExc_TypeError, "addPoolObjects expects a list of plKeys"); return NULL; } addend[i] = *key->fThis; } self->fThis->getPoolObjects().insert(self->fThis->getPoolObjects().end(), addend.begin(), addend.end()); Py_INCREF(Py_None); return Py_None; }
int main(int argc, char**argv) { FreqNode *root; char *alltext; FreqNode *buffer[256] = { NULL }; NodeLList *txtfreqs = newlist(); NodeLList *auxlist; Stack *auxstack; char auxchar; char auxchar2; int i, j; int numvalidsymbols; int highestfreq; int isfirst; if (argc == 1) { printf("Error: Missing filename as argument.\n"); exit(-1); } alltext = readfile(argv[1], buffer); numvalidsymbols = 0; for (i = 0; i < 256; i++) { if (buffer[i] && strcmp(buffer[i]->sym, " ") >= 0 && strcmp(buffer[i]->sym, "~") <= 0 ) { numvalidsymbols++; } } isfirst = 1; for (i = 0; i < numvalidsymbols; i++) { for (j = 32; j < 127; j++) { if (buffer[j] && isfirst) { highestfreq = j; isfirst = 0; } else if (buffer[j] && buffer[j]->freq > buffer[highestfreq]->freq) { highestfreq = j; } } addend(&txtfreqs, buffer[highestfreq]); buffer[highestfreq] = NULL; isfirst = 1; } auxlist = copylist(txtfreqs); root = huffman(&txtfreqs, numvalidsymbols-1); auxstack = newstack(); auxchar = 0 << 7 | 0 << 6 | 0 << 5 | 0 << 4 | 0 << 3 | 0 << 2 | 0 << 1 | 0 << 0; push(&auxstack, auxchar); generatehuffcodes(&root, &auxstack, 0); writefile(argv[1], alltext, root, auxlist, numvalidsymbols); return 0; }