开发者

Optimize memory usage, code selection

I am working on a quite big project: The program has to do multiple tasks at the same time and each of them does hundreds of complicated calculations each second. The program has to be working 24/7. As I am not a proffessionnal programmer and I don't know how memory and CPU is handled by this kind of program, I request your help.

The program has different functions to do during the week and than during the weekend. I know two languages pretty well, Python and C#.

  1. I need this appli开发者_JS百科cation to be fast, so for the calculations I think c# will handle them more quickly.

  2. The program has to work 24/7 so I might think that a Python written project with several little scripts that call eachother for the multiples tasks working permanently, would work better than a Big C# code.

  3. How to write it the best way?

I am thinking of writing it in pseudo-code like

// During the week
function1 ()
{
    do
    {
        ...
        huge code and functions call here
        ...
    }
    while DateTime < Friday 23:59

    if DateTime = Friday 23:59
    {
        function2()
        function1.close
    }
}

// During the weekend
function2 ()
{
    do
    {
        ...
        different code and functions call here
        ...
    }
    while DateTime < Sunday 23:59

    if DateTime = Sunday 23:59
    {
        function1()
        function2.close
    }
}

What is the best approach for this problem? It is a quite large question but any kind advice is welcomed. Thanks

EDIT Question is: the program is quite complicated with hundreds of functions and calculations. I want it to be the fastest and lowest memory consuming. How to write it best?


If you need speed, numpy can help you, it's really fast (it's based on atlas, blas, lapack). I don't know if you can use it in C#.

If you have a lot of calculations to do, you should find a way to store results in case something crash. Moreover maybe you can find a way to optimize using cache. Otherwise you can try using several computer using libs like "mpi". Anyway, you should consider those points in order to be able to be scalable.

Depending on where is the calculations cost python could be a good choice as c#. If the calculations could be done using a third library then it doesn't really matter.

But i agree with obrok, avoid mix languages and try to keep it simple as possible.

For memory maybe using cache could be a good thing or you should cut your calculations into smaller part. Looking into numpy/scipy functions could help you.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜