Пример #1
0
void sequential_demo(int work_count, work_t* works, int seconds_per_work) {
    PRINT("*** SEQUENTIAL DEMO ***\n\n");
    EXPLAIN("  I'm going to run %d works sequentially, one after another.\n", work_count);
    EXPLAIN("  Each work will run for %d seconds.\n\n", seconds_per_work);
    int i;
    for (i = 0; i < work_count; ++i) {
        work_explain(&works[i]);
        PAUSE("Press [Enter] to start this work...\n");
        REF("Estimated resource usage for the following %d seconds\n", seconds_per_work);
        REF("CPU usage:\n");
        REF("\tuser:   about %d%%\n", 100 * usrcpu_usage(1, &works[i]) / cpucount());
        REF("\tsystem: about %d%%\n", 100 * syscpu_usage(1, &works[i]) / cpucount());
        REF("Memory usage:\n");
        REF("\t%ld bytes\n", mem_usage(1, &works[i]));
        REF("Thread usage:\n");
        REF("\ttotal:  1\n");
        REF("\tlocked: 0\n\n");
        work_run(&works[i], seconds_per_work * MICROS_PER_SECOND);
        PRINT("\n");
    }
}
Пример #2
0
void work_explain(work_t* work) {
    EXPLAIN("work %d: ", work->id);
    switch (work->cpu_usage) {
        case cpu_idle:
            EXPLAIN("sleeps all the time keeping CPU idle");
            break;
        case cpu_usr:
            EXPLAIN("loads 1 of your %d CPUs with calculations", cpucount());
            break;
        case cpu_sys:
            EXPLAIN("loads 1 of your %d CPUs writing to a file", cpucount());
            break;
    }
    if (work->mem_size) {
        EXPLAIN(", uses %ld bytes of memory", work->mem_size);
    }
    EXPLAIN("\n");
}
Пример #3
0
static widget_value *
merge_widget_value (widget_value *val1,
                    widget_value *val2,
                    int level,
                    int *change_p)
{
  change_type change, this_one_change;
  widget_value* merged_next;
  widget_value* merged_contents;

  if (!val1)
    {
      if (val2)
	{
	  *change_p = 1;
	  return copy_widget_value_tree (val2, STRUCTURAL_CHANGE);
	}
      else
	return NULL;
    }
  if (!val2)
    {
      *change_p = 1;
      free_widget_value_tree (val1);
      return NULL;
    }

  change = NO_CHANGE;

  if (safe_strcmp (val1->name, val2->name))
    {
      EXPLAIN (val1->name, change, STRUCTURAL_CHANGE, "name change",
	       val1->name, val2->name);
      change = max (change, STRUCTURAL_CHANGE);
      dupstring (&val1->name, val2->name);
    }
  if (safe_strcmp (val1->value, val2->value))
    {
      EXPLAIN (val1->name, change, VISIBLE_CHANGE, "value change",
	       val1->value, val2->value);
      change = max (change, VISIBLE_CHANGE);
      dupstring (&val1->value, val2->value);
    }
  if (safe_strcmp (val1->key, val2->key))
    {
      EXPLAIN (val1->name, change, VISIBLE_CHANGE, "key change",
	       val1->key, val2->key);
      change = max (change, VISIBLE_CHANGE);
      dupstring (&val1->key, val2->key);
    }
  if (! EQ (val1->help, val2->help))
    {
      EXPLAIN (val1->name, change, VISIBLE_CHANGE, "help change",
	       val1->help, val2->help);
      change = max (change, VISIBLE_CHANGE);
      val1->help = val2->help;
    }
  if (val1->enabled != val2->enabled)
    {
      EXPLAIN (val1->name, change, VISIBLE_CHANGE, "enablement change",
	       val1->enabled, val2->enabled);
      change = max (change, VISIBLE_CHANGE);
      val1->enabled = val2->enabled;
    }
  if (val1->button_type != val2->button_type)
    {
      EXPLAIN (val1->name, change, VISIBLE_CHANGE, "button type change",
	       val1->button_type, val2->button_type);
      change = max (change, VISIBLE_CHANGE);
      val1->button_type = val2->button_type;
    }
  if (val1->selected != val2->selected)
    {
      EXPLAIN (val1->name, change, VISIBLE_CHANGE, "selection change",
	       val1->selected, val2->selected);
      change = max (change, VISIBLE_CHANGE);
      val1->selected = val2->selected;
    }
  if (val1->call_data != val2->call_data)
    {
      EXPLAIN (val1->name, change, INVISIBLE_CHANGE, "call-data change",
	       val1->call_data, val2->call_data);
      change = max (change, INVISIBLE_CHANGE);
      val1->call_data = val2->call_data;
    }

  if (level > 0)
    {
      merged_contents =
	merge_widget_value (val1->contents, val2->contents, level - 1,
			    change_p);

      if (val1->contents && !merged_contents)
	{
	  /* This used to say INVISIBLE_CHANGE,
	     but it is visible and vitally important when
	     the contents of the menu bar itself are entirely deleted.

	     But maybe it doesn't matter.  This fails to fix the bug.  */
	  EXPLAIN (val1->name, change, STRUCTURAL_CHANGE, "(contents gone)",
		   0, 0);
	  change = max (change, STRUCTURAL_CHANGE);
	}
      else if (merged_contents && merged_contents->change != NO_CHANGE)
	{
	  EXPLAIN (val1->name, change, INVISIBLE_CHANGE, "(contents change)",
		   0, 0);
	  change = max (change, INVISIBLE_CHANGE);
#if 0 /* This was replaced by the August 9 1996 change in lwlib-Xm.c.  */
#ifdef USE_MOTIF
	  change = max (merged_contents->change, change);
#endif
#endif
	}

      val1->contents = merged_contents;
    }

  this_one_change = change;

  merged_next = merge_widget_value (val1->next, val2->next, level, change_p);

  if (val1->next && !merged_next)
    {
      EXPLAIN (val1->name, change, STRUCTURAL_CHANGE, "(following gone)",
	       0, 0);
      change = max (change, STRUCTURAL_CHANGE);
    }
  else if (merged_next)
    {
      if (merged_next->change)
	EXPLAIN (val1->name, change, merged_next->change, "(following change)",
		 0, 0);
      change = max (change, merged_next->change);
    }

  val1->next = merged_next;

  val1->this_one_change = this_one_change;
  val1->change = change;

  if (change > NO_CHANGE && val1->toolkit_data)
    {
      *change_p = 1;
      if (val1->free_toolkit_data)
	XtFree (val1->toolkit_data);
      val1->toolkit_data = NULL;
    }

  return val1;
}
Пример #4
0
void rwlock_demo(int readers, int writers, work_t* works, int seconds) {
    EXPLAIN("RW-locks are not supported on this platform\n");
    PAUSE("Press [Enter] to skip...\n");
}