本文整理汇总了C++中Console::Write方法的典型用法代码示例。如果您正苦于以下问题:C++ Console::Write方法的具体用法?C++ Console::Write怎么用?C++ Console::Write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Console
的用法示例。
在下文中一共展示了Console::Write方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
void ConsoleState::Update(const ActionMap & actions, unsigned int tElapsed) {
const InputState & input = *actions.GetInputState();
if (input.KeyDown(SDLKey::SDLK_PAGEUP))
console.ScrollUp(3);
if (input.KeyDown(SDLKey::SDLK_PAGEDOWN))
console.ScrollDown(3);
if (!input.KeyDown(SDLKey::SDLK_BACKQUOTE))
_input->Update(actions, tElapsed);
if (input.KeyDown(SDLKey::SDLK_RETURN)) {
ConsoleCommand c = _parseCommand(_input->GetText());
if (c.Command == "dumplog") {
if (c.Params.size() > 0)
console.Write(c.Params.at(0).c_str());
else
console.Write("console.log");
console.AddLine("Successfully wrote console log to file!");
} else if (c.Command == "showfps") {
Preferences.SetValue<bool>("SHOWFPS", !Preferences.GetValue<bool>("SHOWFPS"));
if (Preferences.GetValue<bool>("SHOWFPS"))
console.AddLine("Frames per second display on.");
else
console.AddLine("Frames per second display off.");
} else
console.AddLine(std::string("[echo] ") + _input->GetText());
_input->SetText(std::string(""));
}
}
示例2: main
int main(int argc, char * *argv)
{
Console *console = new Console();
/* Begin your application here. */
CrissCross::Data::DArray<char *> randomStrings;
CrissCross::System::Stopwatch sw;
console->SetColour(console->FG_RED | console->FG_INTENSITY);
console->WriteLine("CheckMark");
console->SetColour();
console->WriteLine("A checksum (hashing) algorithm benchmark.");
console->WriteLine();
console->WriteLine("Note: {whatever}Marks are a measurement of how many %s\nof data were processed per second by a given hash.",
#ifdef TARGET_OS_NDSFIRMWARE
"kilobytes");
#else
"megabytes");
#endif
console->WriteLine();
/* Generate some data for checksum speed tests. */
console->Write("Generating data... ");
sw.Start();
GenerateRandom(randomStrings);
sw.Stop();
console->WriteLine("%5.3lfs", sw.Elapsed());
console->WriteLine();
/* This variable just makes the compiler think */
/* the data is being used somehow. */
unsigned long killOptimization = 0;
sw.Start();
for (int r = 0; r < MAX_RUNS; r++)
for (int i = 0; i < DATASET_SIZE; i++) {
killOptimization = adler32(0, randomStrings.get(i), ENTRY_LENGTH);
}
sw.Stop();
console->WriteLine("%8lu AdlerMarks",
(unsigned long)((double)(DATASET_SIZE * MAX_RUNS) / sw.Elapsed()),
killOptimization);
sw.Start();
for (int r = 0; r < MAX_RUNS; r++)
for (int i = 0; i < DATASET_SIZE; i++) {
killOptimization = crc32(randomStrings.get(i), ENTRY_LENGTH);
}
sw.Stop();
console->WriteLine("%8lu CRCMarks",
(unsigned long)((double)(DATASET_SIZE * MAX_RUNS) / sw.Elapsed()),
killOptimization);
CrissCross::Crypto::MD4Hash md4;
sw.Start();
for (int r = 0; r < MAX_RUNS; r++)
for (int i = 0; i < DATASET_SIZE; i++)
md4.Process(randomStrings.get(i), ENTRY_LENGTH);
sw.Stop();
console->WriteLine("%8lu MD4Marks",
(unsigned long)((double)(DATASET_SIZE * MAX_RUNS) / sw.Elapsed()));
CrissCross::Crypto::MD5Hash md5;
sw.Start();
for (int r = 0; r < MAX_RUNS; r++)
for (int i = 0; i < DATASET_SIZE; i++)
md5.Process(randomStrings.get(i), ENTRY_LENGTH);
sw.Stop();
console->WriteLine("%8lu MD5Marks",
(unsigned long)((double)(DATASET_SIZE * MAX_RUNS) / sw.Elapsed()));
CrissCross::Crypto::SHA1Hash sha1;
sw.Start();
for (int r = 0; r < MAX_RUNS; r++)
for (int i = 0; i < DATASET_SIZE; i++)
sha1.Process(randomStrings.get(i), ENTRY_LENGTH);
sw.Stop();
console->WriteLine("%8lu SHA1Marks",
(unsigned long)((double)(DATASET_SIZE * MAX_RUNS) / sw.Elapsed()));
CrissCross::Crypto::SHA256Hash sha256;
sw.Start();
for (int r = 0; r < MAX_RUNS; r++)
for (int i = 0; i < DATASET_SIZE; i++)
sha256.Process(randomStrings.get(i), ENTRY_LENGTH);
sw.Stop();
console->WriteLine("%8lu SHA256Marks",
(unsigned long)((double)(DATASET_SIZE * MAX_RUNS) / sw.Elapsed()));
CrissCross::Crypto::SHA512Hash sha512;
sw.Start();
for (int r = 0; r < MAX_RUNS; r++)
for (int i = 0; i < DATASET_SIZE; i++)
//.........这里部分代码省略.........
示例3: RunApplication
int RunApplication(int argc, char * *argv)
{
Console *console = new Console();
/* Begin your application here. */
#ifdef ENABLE_CPUID
CPUID *cpuid = new CPUID();
console->SetColour(console->FG_RED | console->FG_INTENSITY);
console->WriteLine("======================");
console->WriteLine("= CPU IDENTIFICATION =");
console->WriteLine("======================");
console->SetColour(0);
console->WriteLine();
cpuid->Go();
/* NOTES */
/* The Virtual count is the number of processors that the operating system sees, */
/* but does not take into account whether any of the processors counted are */
/* hyperthreads, cores, or truly physical CPUs. */
/* */
/* If the Physical and Logical counts are equal, the number of Physical/Logical is the */
/* core count, because it's a dual core system. */
console->WriteLine("There are %d processors in the system (%d cores per package, %d logical per package).",
cpuid->VirtualCount(),
cpuid->CoresPerPackage(),
cpuid->LogicalPerPackage());
if (cpuid->VirtualCount() > 1 || cpuid->CoresPerPackage() > 1 || cpuid->LogicalPerPackage() > 1) {
if (cpuid->CoresPerPackage() == cpuid->LogicalPerPackage())
console->WriteLine("This is a multi-core system.");
else if (cpuid->CoresPerPackage() > 1 && cpuid->LogicalPerPackage() > cpuid->CoresPerPackage())
console->WriteLine("This is a hyperthreaded multi-core system.");
else if (cpuid->CoresPerPackage() == 1 && cpuid->LogicalPerPackage() > 1)
console->WriteLine("This is a hyperthreaded system.");
if (cpuid->VirtualCount() > cpuid->LogicalPerPackage())
console->WriteLine("This is a multi-processor system.");
} else {
console->WriteLine("This is a single processor system.");
}
/*
* v32 l8 = 32/8 = 4
* v4 l2 = 4/2 = 2
* v2 l2 = 2/2 = 1
* v1 l2 = 1/2 = 0.5
*/
double ratio = (double)cpuid->VirtualCount() / (double)cpuid->LogicalPerPackage();
if ((int)ratio < 1) {
console->WriteLine();
console->SetColour(console->FG_YELLOW | console->FG_INTENSITY);
console->WriteLine("WARNING: Expected at least 1 physical package, but detected %0.1lf. Are you\n"
"running this under a hypervisor?", ratio);
console->SetColour();
}
console->WriteLine();
for (int i = 0; i < MAX_PROCESSORS; i++) {
/* Go through each Virtual processor. */
if (cpuid->proc[i]->Manufacturer != NULL) {
/* Print out the manufacturer string */
console->WriteLine("CPU[%d] Manufacturer: %s", i,
cpuid->proc[i]->Manufacturer);
/* Print out the CPU name string, if available. */
if (strlen(cpuid->proc[i]->ProcessorName) > 0)
console->WriteLine("CPU[%d] Name: %s", i,
cpuid->proc[i]->ProcessorName);
/* Print out Family/Model/Stepping info. */
console->WriteLine("CPU[%d] Family: %d, Model: %d, Stepping: %d", i,
cpuid->proc[i]->Family, cpuid->proc[i]->Model,
cpuid->proc[i]->Stepping);
/* Print out the CPU cache info. */
if (cpuid->proc[i]->caches.size() > 0) {
console->WriteLine("CPU[%d] Caches:", i);
for (size_t j = 0; j < cpuid->proc[i]->caches.size(); j++) {
if (cpuid->proc[i]->caches.valid(j))
console->Write(" %s",
cpuid->proc[i]->caches.get(j));
}
console->WriteLine();
}
/* Print out CPU features (MMX, SSE, and so on). */
console->Write("CPU[%d] Features: ", i);
CrissCross::Data::DArray<const char *> *featureIDs =
cpuid->proc[i]->features.ConvertIndexToDArray();
for (size_t i = 0; i < featureIDs->size(); i++) {
if (featureIDs->valid(i))
//.........这里部分代码省略.........