如何模拟工作负载
我必须编写一个程序(perl、python 或 java)来模拟服务器上的工作负载,这样它需要 2 个参数:
Memory
Time
并且基于这些参数应该启动一个进程,在指定的时间内消耗指定的内存量。内存的最大值可以高达 50-100GB,时间可以长达 12-24 小时。
我不能使用 fork 或多线程,这个进程应该是单线程并且应该连续执行操作(如整数/浮点等)。我也不想进行任何 I/O 操作。
我能想到的最简单的方法是:
1. while(timeSpent < timeLimit || memoryConsumed < memorySpecified){
2. if(memoryConsumed < ){
3. Add random number to ArrayList
4. }else{
5. Multiply all numbers (Do some exception handling to prevent this from overflowing)
6. }
7. }
如果有更好的方法,请告诉我。
谢谢,
阿米特
I have to write a program (perl , python or java) to simulate workload on our server such that it takes 2 arguments :
Memory
Time
And based on these arguments it should start a process that consumes the specified amount of memory for specified amount of time.Max value of memory can be as high as 50-100GB and Time can be upto 12-24 hrs.
I cannot use fork or multi threads, this process should be a single thread and should continuously do operations (like Integer / Floating point etc). I don't want to do any I/O operations also.
The simplest way I could think of was:
1. while(timeSpent < timeLimit || memoryConsumed < memorySpecified){
2. if(memoryConsumed < ){
3. Add random number to ArrayList
4. }else{
5. Multiply all numbers (Do some exception handling to prevent this from overflowing)
6. }
7. }
Please let me know if there is a better way of doing this.
Thanks,
Amit
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
像这样的 python 代码不适合您的需求吗?
Wouldn't something like this python code suit your needs?
我正在使用实用程序stressweather.ou.edu/~apw/projects/stress...尽管对其进行了一些调整以扩展我想要的功能..
感谢你们的帮助。
I am using the utility stress weather.ou.edu/~apw/projects/stress ... though tweaked it a bit to extend the features that I wanted..
Thanks for your help guys.
你的例子看起来很合理,至少第一步是这样。然而,有很多小细节需要正确处理:
在现代机器中分配 50-100 GB,无论您是否会进行 I/O
不管你想要与否(通过页面错误),所以你可能想要重新定义
你的规格在那里。
科学计算应用程序无法摆脱“许多小物体”
范例。您可能希望有一些参数来平衡
“许多小物体”和“几个大物体”。
容器中,您可能会生成一系列页面错误,这些错误可能
操作系统很容易预测,因此在
现实世界中,您可能想添加一些随机性
遍历它。
这是一个比看起来更微妙的问题,很多人都想从简单的甚至标准的测试开始,例如:SETI 或光线追踪器。
Your example seems reasonable, at least for a first step. There are however many little details to get right:
allocation of 50-100 GB in a modern machine you will do I/O whether you
want it or not (by way of page faults), so you may want to redefine
your spec there.
scientific computing apps cannot get by the "many small objects"
paradigm. You many want to have some parameter to balance between
"many small objects" and "few large objects".
container you may generate a sequence of page faults that may
easily be predicted by the OS, and therefore unrealistic in the
real world, you may want to add some randomness in the way you
traverse it.
It is a more subtle problem than it seems, and you many want to start simple and perhaps even with standard tests like: SETI or a raytracer.