Here's something cool I'd like to have:

A live what-if functionality for testing code.

Right now I'm trying to do some simple math, like this:

long periodPerBatch = 1000 / batchesPerSec;

And I'm going like this in my head...
MAX_UPDATES is 100 so updatesPerSec divided by 100 is 30 so batchesPerSec is
30.
1000 milliseconds in a second divided by batchesPerSec, which is 30, equals,
eh,
30-something. 30-something divided by batchesPerSec which was, hm, 3000
divided
by 100 equals 30, is 1. 1? One update per batch, thirty batches per second
is not even
close to 3000 updates per second. Oh, it's updatesPerSec, which is 3000,
divided by
batchesPerSec, which was... Argh.

Still with me?

What I'd like to do is just select the code and start the what-if-analyzer.
The analyzer
executes the code and presents the values in a table, like this:

batchesPerSec 30
periodPerBatch 33.33...

Wonderful. I can check in an instant that my math seems reasonable. But what
if
updatesPerSec is 10? Simple, just click 'Add column' and fill in the value.
Like this:

batchesPerSec 30 0
periodPerBatch 33.33... 0-division

Oh dear, there's something wrong with the values. We need a lower bound on
batchesPerSec. I'll edit...

long periodPerBatch = 1000 / batchesPerSec;

Let's look at the analysis again.

batchesPerSec 30 1
periodPerBatch 33.33... 1000

Perfect. Now what about larger numbers...

Can I have this? Pretty please with a donut on top?

/Mikael

1 comment
Permanently deleted user

In the debugger (Alt-F8) switch to Code Fragment Mode,
paste your code fragment, press Evaluate.

--
regards,
--
Alexey Kudravtsev
Software Developer
JetBrains, Inc, http://www.jetbrains.com
"Develop with pleasure!"

"Mikael Karlsson" <mikael.karlsson@pitch.se> wrote in message
news:ev2obn\$h44\$1@is.intellij.net...

Here's something cool I'd like to have:

>

A live what-if functionality for testing code.

>

Right now I'm trying to do some simple math, like this:

>

long periodPerBatch = 1000 / batchesPerSec;

>

And I'm going like this in my head...
MAX_UPDATES is 100 so updatesPerSec divided by 100 is 30 so batchesPerSec
is 30.
1000 milliseconds in a second divided by batchesPerSec, which is 30,
equals, eh,
30-something. 30-something divided by batchesPerSec which was, hm, 3000
divided
by 100 equals 30, is 1. 1? One update per batch, thirty batches per second
is not even
close to 3000 updates per second. Oh, it's updatesPerSec, which is 3000,
divided by
batchesPerSec, which was... Argh.

>

Still with me?

>

What I'd like to do is just select the code and start the
what-if-analyzer. The analyzer
executes the code and presents the values in a table, like this:

>

batchesPerSec 30
periodPerBatch 33.33...

>

Wonderful. I can check in an instant that my math seems reasonable. But
what if
updatesPerSec is 10? Simple, just click 'Add column' and fill in the
value. Like this:

>

batchesPerSec 30 0
periodPerBatch 33.33... 0-division

>

Oh dear, there's something wrong with the values. We need a lower bound on
batchesPerSec. I'll edit...

>

long periodPerBatch = 1000 / batchesPerSec;

>

Let's look at the analysis again.

>

batchesPerSec 30 1
periodPerBatch 33.33... 1000

>

Perfect. Now what about larger numbers...

>

Can I have this? Pretty please with a donut on top?

>

/Mikael

>