示例#1
0
int peano::UserInterface::getMemoryUsageMB() const {
  long u = getMemoryUsage();
  int mega = 1024 * 1024;
  int usageMB ((u + (mega/2)) / mega );

  return usageMB;
}
示例#2
0
int peano::UserInterface::getMemoryUsageKB() const {
  long u = getMemoryUsage();
  int kilo = 1024;
  int usageKB = ((u + (kilo/2)) / kilo );

  return usageKB;
}
示例#3
0
int main(int argc, char* argv[])
{
	#ifdef MEMORY_TEST_INCLUDED
	// Memory used BEFORE creating LinkedList
	long m1 = getMemoryUsage();
	#endif

	if (argc != 2)
	{
		printf("Usage: %s <number of elements to add>\n", argv[0]);
		return 1;
	}

	struct LinkedList* list = linkedListCreate(); 
	int numElements = atoi(argv[1]);
	for (int i = 1 ; i <= numElements; i++)
	{
		linkedListAddBack(list, (TYPE)i);
		linkedListRemoveFront(list);
	}

	linkedListAddBack(list, (TYPE)10);
        linkedListPrint(list);

	#ifdef MEMORY_TEST_INCLUDED
	// Memory used AFTER creating LinkedList
	long m2 = getMemoryUsage();
	printf("Memory used by LinkedList: %ld KB \n", m2 - m1);
	#endif

	double t1 = getMilliseconds(); // Time before contains()
	for (int i = 0; i < numElements; i++)
	{
		linkedListContains(list, i);
	}
	double t2 = getMilliseconds(); // Time after contains()
	printf("Time for running contains() on %d elements: %g ms\n", numElements, t2 - t1);

	linkedListDestroy(list);

	return 0;
}
int main(int argc, char* argv[]) {	
	DynArr* b;
	int n, i;
	double t1, t2;
	#ifdef MEMORY_TEST_INCLUDED
	/* variables to hold memory used before and after creating DynArr */	
	long m1, m2;
	/* memory used BEFORE creating DynArr */
	m1 = getMemoryUsage();
	#endif

	if( argc != 2 ) return 0;
	  
	b = createDynArr(1000); 
	n = atoi(argv[1]); /*number of elements to add*/
		
	for( i = 0 ; i < n; i++) {
		addDynArr(b, (TYPE)i); /*Add elements*/
	}		
	
	#ifdef MEMORY_TEST_INCLUDED
	/* memory used AFTER creating DynArr */
	m2 = getMemoryUsage();  
	printf("Memory used by DynArr: %ld KB \n", m2-m1);
	#endif
	
	t1 = getMilliseconds();/*Time before contains()*/
	
	for(i=0; i<n; i++) {
		containsDynArr(b, i);		
	}	
	
	t2 = getMilliseconds();/*Time after contains()*/
	
	printf("Time for running contains() on %d elements: %g ms\n", n, t2-t1);
  
	/* delete DynArr */
	deleteDynArr(b);
	
	return 0;
}
示例#5
0
QJsonObject Client::getJsonInfo() {
  QJsonObject json;
  json["IP"] = socket.localAddress().toString();
  json["Name"] = getHostname();
  json["CPU"] = getCpuUsage();
  json["Memory"] = getMemoryUsage();
  json["Disk"] = getDiskUsage();
  json["Time"] = currentTime();
  QJsonArray devices = QJsonArray::fromStringList(listAllDevices());
  json["Devices"] = devices;
  return json;
}
int main(int argc, char* argv[])
{
	#ifdef MEMORY_TEST_INCLUDED
	// Memory used BEFORE creating LinkedList
	long m1 = getMemoryUsage();
	#endif

	if (argc != 2)
	{
		printf("Usage: %s <number of elements to add>\n", argv[0]);
		return 1;
	}
	
	DynArr *a = newDynArr(1024);
	
	int numElements = atoi(argv[1]);
	int i;
	for (i = 0 ; i < numElements; i++)
	{
		addDynArr(a, (TYPE)i);
	}

	#ifdef MEMORY_TEST_INCLUDED
	// Memory used AFTER creating LinkedList
	long m2 = getMemoryUsage();
	printf("Memory used by Dynamic Array : %ld KB \n", m2 - m1);
	#endif

	double t1 = getMilliseconds(); // Time before contains()
	for (i = 0; i < numElements; i++)
	{
		containsDynArr(a, i);
	}
	double t2 = getMilliseconds(); // Time after contains()
	printf("Time for running contains() on %d elements: %g ms\n", numElements, t2 - t1);

	deleteDynArr(a);

	return 0;
}
示例#7
0
  // Test that the peak memory usage is always greater than the current memory
  // usage.
  TEUCHOS_UNIT_TEST(memUtils, currentVsPeak)
  {
    Teuchos::RCP<const Teuchos::Comm<int> > comm =
      Teuchos::DefaultComm<int>::getComm();

    // Get the current and peak memory usage.
    MemUsage mem = getMemoryUsage(*comm);

    // Test that the peak usage is greater than the current usage.
    TEST_COMPARE(mem.peakMin, >=, mem.currMin);
    TEST_COMPARE(mem.peakMax, >=, mem.currMax);
    TEST_COMPARE(mem.peakTot, >=, mem.currTot);
  } // end of TEUCHOS_UNIT_TEST()
示例#8
0
  // Test that memory usage increases after creating a bunch of variables.
  TEUCHOS_UNIT_TEST(memUtils, beforeAndAfter)
  {
    static const size_t NUM(4096);
    MemUsage before, after, diff;
    Teuchos::RCP<const Teuchos::Comm<int> > comm =
      Teuchos::DefaultComm<int>::getComm();

    // Get the initial memory usage.
    before = getMemoryUsage(*comm);

    // Create a bunch of variables to use up some memory.
    char    plainOldChar[NUM];
    int     plainOldInt[NUM];
    double  plainOldDouble[NUM];
    char*   newChar   = new char[NUM];
    int*    newInt    = new int[NUM];
    double* newDouble = new double[NUM];

    // Get the new memory usage and compute the difference.
    after = getMemoryUsage(*comm);
    diff  = after - before;

    // Test that memory usage has increased.
    TEST_COMPARE(after.currMin, >=, before.currMin);
    TEST_COMPARE(after.currMax, >=, before.currMax);
    TEST_COMPARE(after.currTot, >=, before.currTot);
    TEST_COMPARE(after.peakMin, >=, before.peakMin);
    TEST_COMPARE(after.peakMax, >=, before.peakMax);
    TEST_COMPARE(after.peakTot, >=, before.peakTot);

    // Clean up.
    (void)(plainOldChar);   (void)(newChar);
    (void)(plainOldInt);    (void)(newInt);
    (void)(plainOldDouble); (void)(newDouble);
    delete[] newChar;
    delete[] newInt;
    delete[] newDouble;
  } // end of TEUCHOS_UNIT_TEST()
示例#9
0
 //-----------------------------------------------------------------------
 void ResourceManager::checkUsage(void)
 {
     if (getMemoryUsage() > mMemoryBudget)
     {
         OGRE_LOCK_AUTO_MUTEX;
         // unload unreferenced resources until we are within our budget again
         ResourceMap::iterator i, iend;
         iend = mResources.end();
         for (i = mResources.begin(); i != iend && getMemoryUsage() > mMemoryBudget; ++i)
         {
             // A use count of 3 means that only RGM and RM have references
             // RGM has one (this one) and RM has 2 (by name and by handle)
             if (i->second.use_count() == ResourceGroupManager::RESOURCE_SYSTEM_NUM_REFERENCE_COUNTS)
             {
                 Resource* res = i->second.get();
                 if (res->isReloadable())
                 {
                     res->unload();
                 }
             }
         }
     }
 }