Looking for APIs to measure battery use of a process [closed] - c++

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Question Is there an API for Windows and/or Linux that will let me find out which processes are draining battery?
A few notes:
It doesn't have to be precise, I'd be ok with only three levels (low energy cost/fair energy cost/high energy cost) if that's all I can get.
I already have CPU load information, that's not what I am looking for, as experience shows that processes with very low CPU use can nevertheless drain battery by having high I/O, high swapping or frequent wakeups. This is why I'd like to piggyback on whatever the OS is already using: OS developers are much more likely than me to have actually tested this.
I found a partial solution for macOS. See answers.
MSDN doesn't seem to indicate any energy-related API.
I cannot request admin/root rights for running my task manager, so I cannot simply parse the syslogs looking for power usage alerts.

I've found a great reference for how macOS does it.
https://blog.mozilla.org/nnethercote/2015/08/26/what-does-the-os-x-activity-monitors-energy-impact-actually-measure/
That should be fairly easy to follow.

Related

How to run multiple simulations inside containers programmatically? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am developing a website that runs a simulation given a user-submitted script. I tried to follow some Online Judge architectures, but in my case, I need to send user input and receive the output in realtime, like a simulation.
I tried Kubernetes Jobs, but isn't seems so easy to communicate with the container, especially if I need a Kubernetes client on the language that I am working.
So, my question is: Given this scenario, what is the best approach to orchestrate multiple containers with interactive I/O programmatically?
*Obs.: I am not worrying about security yet.
Please take a look at the design of the spark operator:
https://github.com/GoogleCloudPlatform/spark-on-k8s-operator
That has a somewhat similar design to what you’re targeting. Similarly, Argo Workflow is another example:
https://github.com/argoproj/argo

It is posible to restart a PCIe card through code (using C, C++ or .NET)? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I have a PCIe card for communications that often gets an error while connecting and, in order to recovering it, is needed to turn off the PC and then turn on again (a restart is not valid).
Is there any way to reset a PCIe card?
It will be interesting a hardware reset (quit and return supply), but even if there is any function for software reset, I would be interested in.
Thank you.
Even if you'd consider software resets, I think it should be pretty obvious that you cannot do this in an application. Hardware is managed by the OS. What would happen if ordinary applications could power down the video card?!
So, the answer (practically speaking) is no. Your purely theoretical chance (Linux is Open Source) is not an option if you're thinking about .Net and thus Windows.

Should profiling be done on selected platforms or on all the platforms? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Suppose I am developing a general library for multiple platforms: linux, windows, mac, ios and Android. After the library passes the functionality test, in order to improve its performance profiling the library is needed. Then my question is: should i profile it on each different platforms or can I select the most familiar platform and then perform the profiling?
This will depend on what type of optimizations you are planning and how important optimization is. For high level issues, (identifying slow algorithms), it will probably be fine to profile on one platform and the results will be useful on all platforms (as will the resulting improvements). However if you need to dig down to low level issues (assembly, cache optimizations, etc) those will be platform specific and you'll need to work on each platform individually.

Moon phase web service [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am looking for a web service that returns the current moon phase as some kind of string, like "Waxing 88%" or a similar string that I can store later in a database. This is for a mobile app, so would rather not use some of the suggested algorithms to calculate it.
Short of finding this, what is your opinion of calculating this in JavaScript on a device? Will this be too resource intensive?
Based on an article I found describing moon phase calculation, I can tell you already that sending a network request over the internet, waiting for and then parsing a response, and finally dealing with the calculations is far more resource intensive then simply performing arithmetic on the device. It will almost certainly use less computing power, less battery power, and less network bandwidth.
You can find a simplified calculation method here:
http://www.voidware.com/moon_phase.htm
This project uses JavaScript to both calculate and display moon-phase information, and may be more relevant to you:
https://github.com/tingletech/moon-phase

Performance data collection in Linux (API) [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I need some library which has comprehensive set of APIs which can help to collect performance data of current machine. Could be very useful if this library written in C++ or Perl.
Tried to googling, since I don't know right terminology for that I found a lot of big and already established projects, which I cannot embed into my code.
What you are looking for is called PAPI Performance Application Programming Interface. It lets you collect data on all performance counters available e.g. FLOP (floating point operations) if you wish to validate your theoretical FLOP count. It also offers an API to compute MFLOPS or even find the cache hit ratio for your application. I have used the library extensively in supporting platforms in addition to Intel VTune.
Here is a list of "native" PAPI events but everything else you will find as CPU native counters.