Image noise: Difference between revisions
Content added Content deleted
m (→{{header|C}}: notify SDL lib) |
No edit summary |
||
Line 330: | Line 330: | ||
With this revision, on my laptop, I typically get in the range of 58..59 FPS, with a cpu load from J of about 3% (sometimes as much as 5%, sometimes as low as 0.1%). I am probably limited by v-sync, and (hypothetically speaking) if I tuned my opengl drivers I perhaps could get significantly faster fps. However, since my screen only refreshes approximately 60 times per second, anything over that would be meaningless. |
With this revision, on my laptop, I typically get in the range of 58..59 FPS, with a cpu load from J of about 3% (sometimes as much as 5%, sometimes as low as 0.1%). I am probably limited by v-sync, and (hypothetically speaking) if I tuned my opengl drivers I perhaps could get significantly faster fps. However, since my screen only refreshes approximately 60 times per second, anything over that would be meaningless. |
||
=={{header|Javascript}}== |
|||
Uses the html5 canvas element. Note: this script requires a html page with a canvas element present, having id=c. |
|||
<lang javascript> |
|||
<body> |
|||
<canvas id='c'></canvas> |
|||
<script> |
|||
var canvas = document.getElementById('c'); |
|||
var ctx = canvas.getContext('2d'); |
|||
var w = canvas.width = 320; |
|||
var h = canvas.height = 240; |
|||
var t1 = new Date().getTime(); |
|||
var frame_count = 0; |
|||
ctx.font = 'normal 400 24px/2 Unknown Font, sans-serif'; |
|||
function animate() { |
|||
ctx.clearRect(0, 0, w, h); |
|||
ctx.fillStyle = "black"; |
|||
for (var x = 0; x < w; x++) |
|||
for (var y = 0; y < h; y++) |
|||
if (Math.random() > 0.5) |
|||
ctx.fillRect(x, y, 1, 1); |
|||
frame_count++; |
|||
var fps = frame_count / (new Date().getTime() - t1) * 1000; |
|||
ctx.fillStyle = "red"; |
|||
ctx.fillText(fps.toFixed(2) + " fps", 20, 40); |
|||
setTimeout(animate, 0); |
|||
} |
|||
animate(); |
|||
</script> |
|||
</body> |
|||
</lang> |
|||
=={{header|OCaml}}== |
=={{header|OCaml}}== |