Re: g++ v14.1.0

Liste des GroupesRevenir à cl c++ 
Sujet : Re: g++ v14.1.0
De : Bonita.Montero (at) *nospam* gmail.com (Bonita Montero)
Groupes : comp.lang.c++
Date : 18. Dec 2024, 10:22:14
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vju483$27u30$1@raubtier-asyl.eternal-september.org>
References : 1 2 3
User-Agent : Mozilla Thunderbird
Am 17.12.2024 um 16:49 schrieb Student Project:
On 17/12/2024 06:52, Bonita Montero wrote:
Am 17.12.2024 um 05:39 schrieb Student Project:
>
Do you guys see any problems in this simple code:
struct Timer
{
     std::chrono::time_point<std::chrono::steady_clock> start, end;
     std::chrono::duration<float> duration;
>
     Timer()
     {
         start = std::chrono::high_resolution_clock::now();
      std::chrono::time_point<std::chrono::high_resolution_clock> start,
end;
>
>
     }
>
     ~Timer()
     {
         end = std::chrono::high_resolution_clock::now();
         duration = end - start;
>
         float ms = duration.count() * 1000.0f;
         std::cout << "Timer took: " << ms << "ms\n";
     }
};
>
>
That's while steady_clock and system_clock are the same with MSVC
(both rely on GetSystemTimeAsFileTime()).
 Vielen Dank, Bonita. Es lässt sich jetzt in allen drei Compilern
kompilieren, auf die ich Zugriff habe. Das vollständige, einfache
Programm zum Ausprobieren finden Sie hier:
 #include <iostream>
#include <chrono>
#include <thread>
 /*
* Compile directives:
For g++:
g++ -std=c++20 -Wall -o obj/main.o -c src/main.cpp
g++ -std=c++20 -Wall -o Program obj/main.o
 For clang++:
clang++ -o Program01.exe -Wall main.cpp
 For Visual Studio:
cl /EHsc main.cpp
 */
 struct Timer
{
  std::chrono::time_point<std::chrono::high_resolution_clock> start, end;
std::chrono::duration<float> duration;

Timer()
{
start = std::chrono::high_resolution_clock::now();
}

~Timer()
{
end = std::chrono::high_resolution_clock::now();
duration = end - start;
  float ms = duration.count() * 1000.0f;
std::cout << "Timer took: " << ms << "ms\n";
}
};
 void Function()
{

Timer timer;
for (int i = 0; i < 1000; i++)
{
std::cout << "Hello World!\n";
}
}
 int main()
{
Function();
}
  Frohe Weihnachten.
 


Date Sujet#  Auteur
17 Dec 24 * g++ v14.1.04Student Project
17 Dec 24 `* Re: g++ v14.1.03Bonita Montero
17 Dec 24  `* Re: g++ v14.1.02Student Project
18 Dec 24   `- Re: g++ v14.1.01Bonita Montero

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal