thenewkgb wrote: Fri Jan 10, 2025 1:09 pm https://pastebin.com/u3kFMq2M
1 month.
I removed iomanip and chrono. Give it a try. Your console output might be better than my phone's. Linux made all digits and characters equal length. Cxxdroid kinda throws them onto the screen.
If the process isn't as easy, that is not as simple as copy paste, what procedure do you need to make it compile?

You can use assembly for tasks that cannot be used in c++98(I only know this for the timer for x86 processors(TSC), I don't know any other).
Code: Select all
// Function to read the processor's Time Stamp Counter (TSC)
unsigned long long read_tsc() {
unsigned int low, high;
__asm__ volatile (
"rdtsc" // Assembly instruction to read the TSC
: "=a" (low), "=d" (high) // Output: low and high 32 bits of TSC
);
return ((unsigned long long)high << 32) | low; // Combine high and low to form the 64-bit result
}
int main() {
unsigned long long tsc1 = read_tsc();
// Perform some time-consuming operation
for (volatile int i = 0; i < 1000000; ++i);
unsigned long long tsc2 = read_tsc();
// Calculate the time difference
unsigned long long elapsed = tsc2 - tsc1;
// Store the result in a variable for later use
unsigned long long result = elapsed;
// Pause the program using a time-consuming loop
for (volatile unsigned long long j = 0; j < 1000000000; ++j);
// Terminate the program
__asm__ volatile (
"mov $1, %%eax;" // System call number for sys_exit
"xor %%ebx, %%ebx;" // Clear ebx register (exit code 0)
"int $0x80;" // Interrupt for system call
:
:
: "%eax", "%ebx"
);
return 0;
}

The read_tsc function uses the rdtsc assembly instruction to read the processor's Time Stamp Counter (TSC), TSC value is split into two 32-bit parts (low and high), which are then combined to form the 64-bit result.
The difference between tsc1(initial TSC value) and tsc2(final TSC value...) is calculated to determine the elapsed time in clock cycles.
You can create a program without the need of a console or the standard c++ library, just using the c++ keywords, it will run on the CPU and in memory anyway...(it may be useful to create a program that these are some c++98 keywords)
- asm
- bool
- break
- case
- catch
- char
- class
- const
- const_cast
- continue
- default
- delete
- do
- double
- dynamic_cast
- else
- enum
- explicit
- export
- extern
- false
- float
- for
- friend
- goto
- if
- inline
- int
- long
- mutable
- namespace
- new
- operator
- private
- protected
- public
- register
- reinterpret_cast
- return
- short
- signed
- sizeof
- static
- static_cast
- struct
- switch
- template
- this
- throw
- true
- try
- typedef
- typeid
- typename
- union
- unsigned
- using
- virtual
- void
- volatile
- wchar_t
- while