Multi-threading for multi-core processors

前端 未结 1 1541
灰色年华
灰色年华 2021-01-06 16:07

I have Samsung Galaxy S3, which used its own Exynos 4 Quad processor. So I want to optimize my app, that it can use all 4 cores of processor.

So I made some tests:<

相关标签:
1条回答
  • 2021-01-06 17:05

    You can try my tests, in C or Java:

    http://bigflake.com/cpu-spinner.c.txt
    http://bigflake.com/MultiCore.java.txt

    When MultiCore.java is run on a Nexus 4, I see:

    Thread 1 finished in 1516ms (1267234688)
    Thread 3 finished in 1494ms (1519485328)
    Thread 0 finished in 1530ms (51099776)
    Thread 2 finished in 1543ms (-1106614992)
    All threads finished in 1550ms
    

    Update: It's useful to watch the test with systrace. As part of answering a similar question I set up a page that shows the systrace output for this test. You can see how the threads are scheduled, and watch the other two cores spin up.

    0 讨论(0)
提交回复
热议问题