Блог пользователя alibaba

Автор alibaba, 10 лет назад, По-английски

Today, when I try to solve this problem E. Pashmak and Graph, with exactly same code (except variable name) I got TLE when using Java 8 but AC when using Java 7, any ideas why?

Submission:

  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится

»
10 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Disassemble can help you.

  • »
    »
    10 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    The first idea I had when I saw this was: "yes, disassemble your computer" :D

    • »
      »
      »
      10 лет назад, # ^ |
      Rev. 7   Проголосовать: нравится +5 Проголосовать: не нравится

      I do not understand — why the contestant who engaged in writing high-performance code should not be able to go down to low level its program/know implementation details of libraries or JIT? Particularly high ranked contestant.

      What you write in high-level languages does not mean that assebler you no longer need. Qualified performance engineers must have the notion about behavior of programs in all levels.

      Languages specifications or algorithms do not have the performance. Performance has only implementation.

      For Java you have open sources of whole enviroment, plenty of tools for analysis of low level code and benchmarking (for example, JMH), a lot of articles from Oracle's employee. Be cool, don't be lazy code monkeys!

      • »
        »
        »
        »
        10 лет назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        You're reading too deeply into it. I literally just said it was the first idea I got when I read your comment, nothing against assembly...

      • »
        »
        »
        »
        10 лет назад, # ^ |
        Rev. 3   Проголосовать: нравится 0 Проголосовать: не нравится

        Hmm, you should be cool first, no body is code monkeys here! Look into Assembly code is not a good idea, as it only show how this specific code is converted to assembly, but not why, If I want to avoid the same mistake, I need to know the right thing to read. Yes, there are a lot of articles, but I don't know which to start from, as this is not a normal behavior that you can search easily, that why we need a forum for thing like this! People are complaining about your advice as it is hard to read and understand, which show lack of commitment, and If it make you angry, be cool and be patient!

        • »
          »
          »
          »
          »
          10 лет назад, # ^ |
            Проголосовать: нравится 0 Проголосовать: не нравится

          What did you do for yourself in order to find the cause?

          • »
            »
            »
            »
            »
            »
            10 лет назад, # ^ |
            Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

            You are making assumption my friend, you are trying to judge me, and I don't think I need to answer this question :)

»
10 лет назад, # |
  Проголосовать: нравится +2 Проголосовать: не нравится

The best/universal answer for java is

42

Creating new objects is the most vulnerable part of java. Maybe in java 8 they change some optimization.

»
10 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

There is a possibility that Arrays.sort implementation was changed or tweaked between Java 7 and Java 8. It is easy to check — just submit your solution with hand-written sorting routine.

»
10 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Typical Java