开发者

Is there a programming language for contests?

开发者 https://www.devze.com 2023-02-06 23:06 出处:网络
Is there a programming language that measures everything? For instan开发者_Go百科ce, I would like to measure how much memory was allocated, the number of operations used (in terms of cycles), and tim

Is there a programming language that measures everything?

For instan开发者_Go百科ce, I would like to measure how much memory was allocated, the number of operations used (in terms of cycles), and time spent on IO.

Such a language would be great for running a programming contest.


It sounds like you want a tool, not necessarily a language. I use profiling tools to do these sorts of things with embedded C programs. Your compiler vendor may have similar tools available.

The OS is in charge of memory management, so it's probably easiest to get the OS to report that to you. Another option is to write a library that entrants are required to use that builds wrappers around malloc, etc. When the library's malloc is called, it logs how much memory was allocated and calls the real malloc. Once the program terminates, you have a complete log of the dynamic memory usage of the program. You can also write wrappers around I/O functions that log the latency of those functions (take a timestamp before calling the real function and after it completes).


You might consider running a program compiled/interpreted by an existing language under a tool like ValGrind, which can report on these kinds of factors. You could extend ValGrind further if necessary.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号