Home | History | Annotate | Download | only in test
      1 /*
      2  *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
      3  *
      4  *  Use of this source code is governed by a BSD-style license
      5  *  that can be found in the LICENSE file in the root of the source
      6  *  tree. An additional intellectual property rights grant can be found
      7  *  in the file PATENTS.  All contributing project authors may
      8  *  be found in the AUTHORS file in the root of the source tree.
      9  */
     10 
     11 #include <cassert>
     12 #include <iostream>
     13 
     14 #ifdef _WIN32
     15     #include <windows.h>
     16     #include <tchar.h>
     17 #else
     18     #include <stdio.h>
     19     #define Sleep(x) usleep(x*1000)
     20 #endif
     21 
     22 #include "common_types.h"
     23 #include "trace.h"
     24 #include "cpu_wrapper.h"
     25 
     26 
     27 #ifdef _WIN32
     28 int _tmain(int argc, _TCHAR* argv[])
     29 #else
     30 int main(int argc, char* argv[])
     31 #endif
     32 {
     33     Trace::CreateTrace();
     34     Trace::SetTraceFile("testTrace.txt");
     35     Trace::SetLevelFilter(webrtc::kTraceAll);
     36 
     37     printf("Start system wrapper test\n");
     38 
     39     printf("Number of cores detected:%u\n", (unsigned int)CpuWrapper::DetectNumberOfCores());
     40 
     41     CpuWrapper* cpu = CpuWrapper::CreateCpu();
     42 
     43     WebRtc_UWord32 numCores;
     44     WebRtc_UWord32* cores;
     45 
     46     for(int i = 0; i< 10;i++)
     47     {
     48         WebRtc_Word32 total = cpu->CpuUsageMultiCore(numCores, cores);
     49 
     50         printf("\nNumCores:%d\n", (int)numCores);
     51         printf("Total cpu:%d\n", (int)total);
     52 
     53         for (WebRtc_UWord32 i = 0; i< numCores;i++)
     54         {
     55             printf("Core:%lu CPU:%lu \n", i, cores[i]);
     56         }
     57         Sleep(1000);
     58     }
     59 
     60     printf("Done system wrapper test\n");
     61 
     62     delete cpu;
     63 
     64     Trace::ReturnTrace();
     65 };
     66