|
Member 14968771 wrote: This is a test
in few words of plain English ,
Which suggests homework.
But the answer is no.
The question cannot be answered in "plain english" because it require concepts that only exist in programming. So as the other answers suggest one would need to understand what a 'local variable' is and what a 'heap' is for any answer to make sense.
|
|
|
|
|
It's not homework. This member is struggling with basic concepts in C++.
|
|
|
|
|
Please follow up if the explanations helped.
Charlie Gilley
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
Has never been more appropriate.
|
|
|
|
|
Message Closed
modified 15-May-23 19:06pm.
|
|
|
|
|
oh well, suit yourself.
Charlie Gilley
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
Has never been more appropriate.
|
|
|
|
|
I've tried e.g. QueryThreadCycleTime as follows:
#include <windows.h>
#include <iostream>
int main()
{
for (int i = 0; i < 10; ++i)
{
uint64_t n1 = 0, n2 = 0;
BOOL ok1 = QueryThreadCycleTime(GetCurrentThread(), &n1);
BOOL ok2 = QueryThreadCycleTime(GetCurrentThread(), &n2);
if (ok1 && ok2)
std::cout << n2 - n1 << "\n";
else
std::cout << "n/a\n";
}
}
Typical results are:
1036
1114
1734
748
706
670
652
716
652
666
The numbers vary widely - ok, maybe these are expensive calls - but what is the point then?
If I replace the thread cycles with process cycles, numbers get even weirder:
BOOL ok1 = QueryProcessCycleTime(GetCurrentProcess(), &n1);
BOOL ok2 = QueryProcessCycleTime(GetCurrentProcess(), &n2);
With typical results:
39666
39520
304964
145932
47486
287156
191528
208652
196176
288642
This blog post[^] suggests that it should be no worse than QueryPerformanceCounter , but that's not what I'm seeing.
Anyone with insights?
|
|
|
|
|
The number of CPU clock cycles used by the threads of the process. This value includes cycles spent in both user mode and kernel mode. . So it just shows which threads are consuming what. That may allow you to tune your application if it is largely compute bound.
|
|
|
|
|
Your code on my machine:
2716
2793
2768
2617
2977
2708
2686
2795
2731
2651
well, not perfect, but... Let's try another time:
2703
2891
52734
2611
2623
2613
2611
2609
2608
2592
Absolute rubbish laddie!
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
CPallini wrote: Absolute rubbish laddie! I always suspected you were Scottish and not Italian.
|
|
|
|
|
I am... Pink[^]!
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
peterchen wrote: This blog post[^] suggests that it should be no worse than QueryPerformanceCounter, but that's not what I'm seeing.
Anyone with insights?
My translation of what you are asking:
peterchen should have asked:
QueryProcessCycleTime uses the RDTSC instruction. QueryPerformanceCounter historically also used the RDTSC instruction. Why aren't they giving similar outputs?
As you probably already know the TSC is superceeded by the HPET. There are a dozen reasons why RDTSC provides inaccurate results. The Meltdown/Spectre mitigations were probably the nail in the coffin so to speak.
The answer to your question is that QueryPerformanceCounter uses the HPET/APIC clock and QueryProcessCycleTime is still using the old rdtsc instruction.
It's apparently a huge mess, @HaroldAptroot says sometimes QueryPerformanceCounter uses HPET and sometimes it doesn't depending on whether or not the TSC is invariant.
modified 24-Jan-23 15:14pm.
|
|
|
|
|
Randor wrote: As you probably already know the TSC is superceeded by the HPET. Not actually true though, QPC is based on HPET only when necessary, which is basically if you have a CPU that does not have Invariant TSC (and you don't, unless your CPU is from the mid 2000's). QPC is based on the TSC on every reasonable computer.
|
|
|
|
|
Hmmm,
Do you know where I can find a list of processors with an invariant TSC? I see that cpuid has 80000007H to indicate support but where can I find a list of processors that support it?
|
|
|
|
|
Unfortunately I don't know of such a list and I couldn't find one either. There are lists of CPUID dumps.. not very convenient
|
|
|
|
|
Message Closed
modified 15-May-23 19:06pm.
|
|
|
|
|
The fact that C/C++ is a staticly-typed language has nothing to do with static member functions. In turn these have very little to do with static functions in general. They are just 3 different uses for the same word.
Member 14968771 wrote: If I have a C+_+ class and the function is defined as "static" - what is so different from function which is NOT defined as NOT static ?
Regular member functions have one extra hidden parameter, the "this" pointer, that points to the object on which they are called. Static member functions don't have this hidden parameter and are very much like any regular function except for some scoping rules.
"Static", like "object" and "module" are a very abused words in programming.
Mircea
|
|
|
|
|
Member 14968771 wrote: If I have a C+_+ class and the function is defined as "static" - what is so different from function which is NOT defined as NOT static ? A non-static member function is always called via an object reference. That is any call of the form:
obj.SomeMethod();
has access to all the properties of that particular instance.
But for a static method called thus:
ClassName::StaticMethod();
has no such access, and can only access static members of the class.
But I am not sure that that was your question.
Maybe some C++ learning is in order.
ps, please do not SHOUT in your messages, it is unnecessary and rude.
|
|
|
|
|
Member 14968771 wrote: will not. when used as STATIC.
Presumably you mean...
First you tried something without 'static' in place and it worked.
Second you put 'static' somewhere and now it doesn't work. The console output does not show up.
Not really a lot of information there. So the following are some possibilities for that behavior.
- You recompiled, it failed, and then when you ran something it did not find the binary. So it didn't actually run.
- You recompiled, it worked (because someone has some 'clever' code) and it failed with an exception. But you did not see that exception output or ignored it.
- You recompiled, it worked (because someone has some 'clever' code) and that other code worked. But you did not see any output because the actual method that was called, which is a different one, does not do console output.
|
|
|
|
|
Hi...
We need some program.
We are using a POS equipment. some program must be printed by POS.
before printing we need a hooking a text message from com port.
- When the program start. we must find a com port which com port is conneced with POS equipment.
- Whenever the com port is used for printing. the text message must be returened to some way.
- the way can be suggested to you. This text message will be used by another program.
|
|
|
|
|
|
|
You are describing a case where you have an existing application flow: Serial port to POS.
And you want to put monitoring place to see what that serial traffic looks like. So you don't want to replace or modify the existing code but rather just see what is happening.
So you should google for the following
windows serial port intercept
That said however I would suggest that if the POS code is under your control that the POS code itself should be modified to provide the same sort of monitoring. Log files (search for libraries) can both be used to control and collect such data.
|
|
|
|
|
Meanwhile "member" - describe your background. Still in school?
Charlie Gilley
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
Has never been more appropriate.
|
|
|
|
|
Message Closed
modified 15-May-23 19:06pm.
|
|
|
|
|
This should work:
for(auto& adapter : localAdapters)
{
qDebug()<< " local adapter address" << adapter.address().toString();
ui->chat_10->append( adapter.address().toString());
qDebug() << " local adapater name " << adapter.name();
ui->chat_10->append( adapter.name());
}
Mircea
|
|
|
|