<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic timing a simulation in 3ds Max Programming Forum</title>
    <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/timing-a-simulation/m-p/9326048#M7095</link>
    <description>&lt;P&gt;I'm working on a couple scripts that will be used to benchmark various hardware, but I'm struggling with timing a simulation. Basically I want to start a simulation and see how long it takes to perform 50 or 100 frames. Any suggestions? I assuming some sort of callback, or using IsSolverRunning() but have come up empty.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 18 Feb 2020 18:25:38 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-02-18T18:25:38Z</dc:date>
    <item>
      <title>timing a simulation</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/timing-a-simulation/m-p/9326048#M7095</link>
      <description>&lt;P&gt;I'm working on a couple scripts that will be used to benchmark various hardware, but I'm struggling with timing a simulation. Basically I want to start a simulation and see how long it takes to perform 50 or 100 frames. Any suggestions? I assuming some sort of callback, or using IsSolverRunning() but have come up empty.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2020 18:25:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/timing-a-simulation/m-p/9326048#M7095</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-18T18:25:38Z</dc:date>
    </item>
    <item>
      <title>Re: timing a simulation</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/timing-a-simulation/m-p/9328909#M7096</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope I get the question correctly.&lt;BR /&gt;You are trying to measure time a simulation takes to run using maxscript ?&lt;BR /&gt;&lt;BR /&gt;If so.&lt;BR /&gt;Maxscript will wait for the simulation to end before continuing to next line, using timestamp() should give you the start and end time of the simulation.&lt;/P&gt;
&lt;PRE&gt;start_time = timestamp()
-- run simulation code
end_time = timestamp()
total_time = (end_time - start_time) 
format "Simulation took % milliseconds.\n" total_time
format "Simulation took % seconds.\n" (total_time / 1000.0 )&lt;/PRE&gt;
&lt;P&gt;If that does not work as you expect, what Simulation is being ran in Max ?&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 18:54:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/timing-a-simulation/m-p/9328909#M7096</guid>
      <dc:creator>ads_royje</dc:creator>
      <dc:date>2020-02-19T18:54:25Z</dc:date>
    </item>
    <item>
      <title>Re: timing a simulation</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/timing-a-simulation/m-p/9329140#M7097</link>
      <description>&lt;P&gt;I tried doing:&lt;/P&gt;&lt;P&gt;startTime = timeStamp()&lt;BR /&gt;solver.runsolve()&lt;BR /&gt;endTime = timeStamp()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but that just returns:&lt;/P&gt;&lt;PRE&gt;44010860
true
44011095
235
Simulation took 235 milliseconds.
OK
Simulation took 0.235 seconds.
OK
OK&lt;/PRE&gt;&lt;P&gt;that doesn't seem like it is waiting for the end before moving to the next line. The simulation runs for about a full minute&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 20:24:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/timing-a-simulation/m-p/9329140#M7097</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-19T20:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: timing a simulation</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/timing-a-simulation/m-p/9330700#M7098</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&amp;nbsp;!&lt;BR /&gt;&lt;BR /&gt;Ha, I see, you are using Fluids! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;That is a different system indeed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you were suspecting, you are right. You need to use IsSolverRunning() to pause the script while Fluids is calculating the solve.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;The easiest approach is the use: while (isSolverRunning) do ()&lt;BR /&gt;Given a Fluid object named "Liquid001" with 1 solver&lt;/P&gt;
&lt;PRE&gt;start_time = timestamp()
$Liquid001.solvers[1].runSolve()
while ($Liquid001.solvers[1].IsSolveRunning()) do
(
-- while Fluids is running, do nothing, so script waits for the end of Fluid's calculation before going any further
)

end_time = timestamp()
total_time = (end_time - start_time) 
format "Simulation took % milliseconds.\n" total_time
format "Simulation took % seconds.\n" (total_time / 1000.0 )&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;Let me know if that works for you or not,&lt;BR /&gt;Regards,&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2020 13:11:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/timing-a-simulation/m-p/9330700#M7098</guid>
      <dc:creator>ads_royje</dc:creator>
      <dc:date>2020-02-20T13:11:26Z</dc:date>
    </item>
    <item>
      <title>Re: timing a simulation</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/timing-a-simulation/m-p/9340691#M7099</link>
      <description>&lt;P&gt;That works perfectly. Thank you! Its interesting that its different. I'm developing a benchmark suit for Max to test hardware performance, so I'll have to dig into this a bit more. I'm sure I'll be back with plenty more questions.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2020 17:33:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/timing-a-simulation/m-p/9340691#M7099</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-25T17:33:44Z</dc:date>
    </item>
  </channel>
</rss>

