Performance improvements due to conditional parsing of IO data depending on selected fields.

On my machine, this gives a ~20% improvement in htop process time use with the default config.
This commit is contained in:
Hisham Muhammad
2013-05-24 22:46:01 +00:00
parent 5c2d84aba3
commit 6cfa9e0bf2
7 changed files with 61 additions and 6 deletions

View File

@ -82,11 +82,13 @@ static bool Settings_read(Settings* this, char* fileName, int cpuCount) {
char** ids = String_split(trim, ' ', &nIds);
free(trim);
int i, j;
this->pl->flags = 0;
for (j = 0, i = 0; i < LAST_PROCESSFIELD && ids[i]; i++) {
// This "+1" is for compatibility with the older enum format.
int id = atoi(ids[i]) + 1;
if (id > 0 && id < LAST_PROCESSFIELD) {
this->pl->fields[j] = id;
this->pl->flags |= Process_fieldFlags[id];
j++;
}
}