VOL::core底層使用說明-2

來源:互聯網
上載者:User
文章目錄
  • Platfrom使用例子
  • Hash使用例子
Platfrom使用例子

類似上面”Hello World!”例子, 在原來的解決方案中建立一個新的項目

 

#include
"stdafx.h"

 

using namespace VOL;

 

int _tmain(int argc, _TCHAR* argv[])

{

     // 擷取VOL::core編譯時間的資訊

     ULong ulRuntime =CPlatform::GetRuntimeType();

     DEV_INFO(TF("---Platform Information---"));

     DEV_INFO(TF(" %s"), (ulRuntime &CPlatform::RUNTIMET_DEBUG)   ?

                         TF("Debug Build") : TF("Release Build"));

     DEV_INFO(TF(" %s"), (ulRuntime & CPlatform::RUNTIMET_X86)     ?

                         TF("32-bitArchitecture") : TF("64-bitArchitecture"));

     DEV_INFO(TF(" %s"), (ulRuntime &CPlatform::RUNTIMET_WINDOWS) ?

                         TF("Windows Depends") : TF("Unknown Depends"));

     DEV_INFO(TF(" %s"), (ulRuntime &CPlatform::RUNTIMET_UNICODE) ?

                          TF("Characterset: Use Unicode Character Set") :

                         TF("Characterset: Use Multi-Byte Character Set"));

     DEV_INFO(TF(" %s"), (ulRuntime &CPlatform::RUNTIMET_LIBLINK) ?

                          TF("StaticLibrary Version") : TF("DynamicLibrary Version"));

    

     // 擷取當前運行CPU資訊

     CPlatform::CPUINFO cpu;

     CPlatform::GetCPUInfo(cpu);

     DEV_INFO(TF("---CPU Identifier & Features---"));

     DEV_INFO(TF(" %s:%s"), (cpu.ulTechSupport &CPlatform::CPUT_INTEL)     ?

                         TF("Intel"): TF("AMD"), cpu.szID);

     DEV_INFO(TF(" Cores : %d, Speed %dMHz"),cpu.ulPhysicalCount, cpu.ulSpeed);

     DEV_INFO(TF(" Features : %s, %s, %s, %s, %s, %s, %s, %s"),

                          (cpu.ulTechSupport &CPlatform::CPUT_SSE2)      ?

                           TF("SSE2[YES]"): TF("SSE2[NO]"),

                          (cpu.ulTechSupport &CPlatform::CPUT_HTT)       ?

 TF("HTT[YES]")  : TF("HTT[NO]"),

 (cpu.ulTechSupport &CPlatform::CPUT_3DNOW)     ?

TF("3DNOW[YES]"): TF("3DNOW[NO]"),

 (cpu.ulTechSupport &CPlatform::CPUT_3DNOWPLUS) ?

TF("3DNOW+[YES]"): TF("3DNOW+[NO]"),

 (cpu.ulTechSupport &CPlatform::CPUT_SSE3)      ?

TF("SSE3[YES]"): TF("SSE3[NO]"),

 (cpu.ulTechSupport &CPlatform::CPUT_SSSE3)     ?

 TF("SSSE3[YES]"): TF("SSSE3[NO]"),

 (cpu.ulTechSupport &CPlatform::CPUT_SSE41)     ?

TF("SSE41[YES]"): TF("SSE41[NO]"),

(cpu.ulTechSupport &CPlatform::CPUT_SSE42)     ?

TF("SSE42[YES]"): TF("SSE42[NO]"));

    

     // 擷取當前運行記憶體使用量資訊

     CPlatform::MEMINFO mem;

     CPlatform::GetMemInfo(mem);

     DEV_INFO(TF("---Memory Information---"));

     DEV_INFO(TF(" Memory Current Used       : % 8d[%%]"),mem.ulUsedPercent);

     DEV_INFO(TF(" Memory Page Size          : % 8d[KB]"),mem.ulPageSize);

     DEV_INFO(TF(" Memory Total Physical Size: % 8d[MB]"),mem.ulTotalPhys);

     DEV_INFO(TF(" Memory Valid Physical Size: % 8d[MB]"),mem.ulAvailPhys);

     DEV_INFO(TF(" Memory Total Pages        : % 8d[MB]"),mem.ulTotalPages);

     DEV_INFO(TF(" Memory Valid Pages        : % 8d[MB]"),mem.ulAvailPages);

     DEV_INFO(TF(" Memory Total Virtual Size : % 8d[MB]"),mem.ulTotalVirtual);

     DEV_INFO(TF(" Memory Valid Virtual Size : % 8d[MB]"),mem.ulAvailVirtual);

    

     // 擷取當前啟動並執行系統資訊

     CPlatform::OSINFO os;

     CPlatform::GetOSInfo(os);

     DEV_INFO(TF("---Operation System Information---"));

     DEV_INFO(TF(" OS Type       : %s"),            (os.ulOSType & CPlatform::OST_WINDOWS) ? TF("Windows"): TF("Unknown"));

     DEV_INFO(TF(" OS Version    : %d.%d Build %d"), os.ulMajor, os.ulMinor, os.ulBuild);

     DEV_INFO(TF(" OS Description : %s"),             os.szDescription);

    

     // 擷取當前本地時間資訊

     CPlatform::TIMEINFO time;

     CPlatform::GetTimeInfo(time);

     DEV_INFO(TF("Current Time : %d-%d-%d(%d), %d-%d-%d-%d"),

                          time.usYear, time.usMonth, time.usDay,time.usWeekDay,

                          time.usHour, time.usMinute,time.usSecond, time.usMSecond);

    

     // 擷取當前MemAid建立局部範圍動態記憶體申請的緩衝大小[預設按記憶體動態計算]

     DEV_INFO(TF("Core MemAid Stack Size : %X[MB]"),CPlatform::GetStackSize());

    

     // 擷取當前ThreadPool由於處理隊列任務的隊列線程數量

     DEV_INFO(TF("Core Thread Pool Queue Thread : %X"),CPlatform::GetQueueThread());

 

     // 擷取當前系統運行了多少時間[CPU周期數和毫秒]

     ULLong ullTick =CPlatform::GetOSRunningTick();

     DEV_INFO(TF("OS running %lld[CPU ticks]"), ullTick);

     ullTick =CPlatform::Tick2MilliSecond(ullTick);

     DEV_INFO(TF("OS running %lld[MS]"), ullTick);

 

     // 擷取VOL::core運行了多少時間[秒]

     ullTick =CPlatform::GetRunningTime();

     DEV_INFO(TF("Core running %lld[S]"), ullTick);

 

     return0;

}

 

運行代碼, 將在調試資訊中輸出編譯VOL::core的資訊和當前運行平台的資訊

Hash使用例子

Hash的主要功能是通過一種演算法(CRC)將輸入的資料來源產生對應的固定數值, 按32位和64位編譯平台的不同,Hash產生的固定數值對應是32和64位

 

類似上面”Hello World!”例子, 在原來的解決方案中建立一個新的項目

Stdafx.h包含Hash標頭檔 #include
"hash.h"

#include
"stdafx.h"

 

using namespace VOL;

 

CPCXStr STR_TEST[] =

{

     TF(""),

     TF("a"),

     TF("ab"),

     TF("abc"),

     TF("abcd"),

     TF("abcde"),

     TF("abcdef"),

     TF("abcdefg"),

     TF("A"),

     TF("aB"),

     TF("abC"),

     TF("abcD"),

     TF("abcdE"),

     TF("abcdeF"),

     TF("abcdefG"),

     TF("A"),

     TF("AB"),

     TF("ABC"),

     TF("ABCD"),

     TF("ABCDE"),

     TF("ABCDEF"),

     TF("ABCDEFG"),

};

 

int _tmain(int argc, _TCHAR* argv[])

{

     for(Int i = 0; i < 21; ++i)

     {

         UHash uhData =CHash::Hash(STR_TEST[i]);

         DEV_INFO(TF("%s hash : %X"), STR_TEST[i], uhData);

     }

 

     HASH_DUMP dump;

     CHash::Dump(dump);

     DEV_INFO(TF("hash : %llX-%llX"), dump.llUsedCount,dump.llUsedTick);

 

     return0;

}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.