Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test code #10

Open
wants to merge 1 commit into
base: br_team_travel_recommendation
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
49 changes: 49 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# set minimum cmake version
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)

# project name and language
project(recipe-05 LANGUAGES CXX)

# define executable
add_executable(processor-info "")

# and its source file
target_sources(processor-info
PRIVATE
processor-info.cpp
)

# and its include directories
target_include_directories(processor-info
PRIVATE
${PROJECT_BINARY_DIR}
)

foreach(key
IN ITEMS
NUMBER_OF_LOGICAL_CORES
NUMBER_OF_PHYSICAL_CORES
TOTAL_VIRTUAL_MEMORY
AVAILABLE_VIRTUAL_MEMORY
TOTAL_PHYSICAL_MEMORY
AVAILABLE_PHYSICAL_MEMORY
IS_64BIT
HAS_FPU
HAS_MMX
HAS_MMX_PLUS
HAS_SSE
HAS_SSE2
HAS_SSE_FP
HAS_SSE_MMX
HAS_AMD_3DNOW
HAS_AMD_3DNOW_PLUS
HAS_IA64
OS_NAME
OS_RELEASE
OS_VERSION
OS_PLATFORM
)
cmake_host_system_information(RESULT _${key} QUERY ${key})
endforeach()

configure_file(config.h.in config.h @ONLY)
23 changes: 23 additions & 0 deletions config.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once

#define NUMBER_OF_LOGICAL_CORES @_NUMBER_OF_LOGICAL_CORES@
#define NUMBER_OF_PHYSICAL_CORES @_NUMBER_OF_PHYSICAL_CORES@
#define TOTAL_VIRTUAL_MEMORY @_TOTAL_VIRTUAL_MEMORY@
#define AVAILABLE_VIRTUAL_MEMORY @_AVAILABLE_VIRTUAL_MEMORY@
#define TOTAL_PHYSICAL_MEMORY @_TOTAL_PHYSICAL_MEMORY@
#define AVAILABLE_PHYSICAL_MEMORY @_AVAILABLE_PHYSICAL_MEMORY@
#define IS_64BIT @_IS_64BIT@
#define HAS_FPU @_HAS_FPU@
#define HAS_MMX @_HAS_MMX@
#define HAS_MMX_PLUS @_HAS_MMX_PLUS@
#define HAS_SSE @_HAS_SSE@
#define HAS_SSE2 @_HAS_SSE2@
#define HAS_SSE_FP @_HAS_SSE_FP@
#define HAS_SSE_MMX @_HAS_SSE_MMX@
#define HAS_AMD_3DNOW @_HAS_AMD_3DNOW@
#define HAS_AMD_3DNOW_PLUS @_HAS_AMD_3DNOW_PLUS@
#define HAS_IA64 @_HAS_IA64@
#define OS_NAME "@_OS_NAME@"
#define OS_RELEASE "@_OS_RELEASE@"
#define OS_VERSION "@_OS_VERSION@"
#define OS_PLATFORM "@_OS_PLATFORM@"
41 changes: 41 additions & 0 deletions processor-info.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include "config.h"

#include <cstdlib>
#include <iostream>

int main() {
std::cout << "Number of logical cores: " << NUMBER_OF_LOGICAL_CORES << std::endl;
std::cout << "Number of physical cores: " << NUMBER_OF_PHYSICAL_CORES << std::endl;

std::cout << "Total virtual memory in megabytes: " << TOTAL_VIRTUAL_MEMORY
<< std::endl;
std::cout << "Available virtual memory in megabytes: " << AVAILABLE_VIRTUAL_MEMORY
<< std::endl;
std::cout << "Total physical memory in megabytes: " << TOTAL_PHYSICAL_MEMORY
<< std::endl;
std::cout << "Available physical memory in megabytes: "
<< AVAILABLE_PHYSICAL_MEMORY << std::endl;

std::cout << "Processor is 64Bit: " << IS_64BIT << std::endl;
std::cout << "Processor has floating point unit: " << HAS_FPU << std::endl;
std::cout << "Processor supports MMX instructions: " << HAS_MMX << std::endl;
std::cout << "Processor supports Ext. MMX instructions: " << HAS_MMX_PLUS
<< std::endl;
std::cout << "Processor supports SSE instructions: " << HAS_SSE << std::endl;
std::cout << "Processor supports SSE2 instructions: " << HAS_SSE2 << std::endl;
std::cout << "Processor supports SSE FP instructions: " << HAS_SSE_FP << std::endl;
std::cout << "Processor supports SSE MMX instructions: " << HAS_SSE_MMX
<< std::endl;
std::cout << "Processor supports 3DNow instructions: " << HAS_AMD_3DNOW
<< std::endl;
std::cout << "Processor supports 3DNow+ instructions: " << HAS_AMD_3DNOW_PLUS
<< std::endl;
std::cout << "IA64 processor emulating x86 : " << HAS_IA64 << std::endl;

std::cout << "OS name: " << OS_NAME << std::endl;
std::cout << "OS sub-type: " << OS_RELEASE << std::endl;
std::cout << "OS build ID: " << OS_VERSION << std::endl;
std::cout << "OS platform: " << OS_PLATFORM << std::endl;

return EXIT_SUCCESS;
}