Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How would I simulate running code on different hardware while using only one machine?

As the title says I'm looking to approximate the performance of a piece of code on different hardware setups. Are there any tools out there to do this?

I'm looking to run my code and perform measurements by limiting the resources available to the process. I would like to control things such as total memory available as well as cpu usage, but it would be better if I had more granularity. Are there any tools out there that would allow me to emulate different speeds of RAM, rate limit the cpu (to say X gigaflops), slow down disk reads, etc?

I've already been looking at the setrlimit command in linux, but I don't think it will let me emulate things like latency. I considered using VMs to run the code and just tweaking the memory and cpu but I'm not sure its granular enough. I also considered things like hooking some of the syscalls and just spinning for x nanoseconds before allowing a read/write syscall, but it feels kind of clunky. The other issue is that this code primarily runs on Windows, and if possible it would be preferable to do this on Windows.

Just for some background, I'm trying to provide some reasonably accurate estimates of things like runtime and resource utilization on different hardware setups without having to actually buy, assemble, and test said hardware.

Thanks for any help you can provide.

like image 672
firro Avatar asked Nov 12 '22 14:11

firro


1 Answers

If you wish to get very detailed control of every possible part of a machine, use a software emulated machine such as Bochs. Bochs will emulate, in software, an x86 CPU, hard drive, video card, network card, everything.

In order to do what you want to do you would need to build your own version of Bochs with changes to the emulator to control the speed of the different pieces.

like image 166
Zan Lynx Avatar answered Dec 05 '22 11:12

Zan Lynx