Use graphics to speed up, easy to make a notebook to create a heater Method! _javascript Tips

Source: Internet
Author: User
Tags cpu usage

Recently, a lot of broken things, for a long time did not come here to write the whimsical thing. But this morning I thought of a very interesting thing, so it took half an hour to simply think about it, and by the way write a little share.

When the weather is cold, or frozen hands frozen feet ~ So this hot notebook just became a hand-baking tool:

The drawback is, usually do not want it hot, the fan is always daze. Now really want to let it hot, but not to power.

The solution is also very simple, hang a 3D game in that, special effects, not hot also not. However, this is to occupy the system resources, as well as their own simple to create a "heater"!

The most heat-generating hardware in a computer is nothing more than CPU and graphics. Let these two hardware non-stop work, fans do not go crazy ~
This is going to use VC to write a simple CPU and GPU consumption of small programs, but like me, Jsfans, any questions will daydream: In the Web can also be achieved? The result of course is definitely drop!
Now the browser support GPU hardware acceleration, as a direct use of JS to achieve it ~ just a few lines of code can be done!

The code is very simple, is constantly rendering the picture. After some streamlining, simply put the picture also removed, directly with a blank canvas instead. Anyway, our goal is not beautiful, just let the hardware work, fever!

Want to try it on the point here: http://www.etherdream.com/FunnyScript/GPUHeater.html (preferably with IE9)


Copy Code code as follows:

<! DOCTYPE html>
<title>Heater</title>
<b Ody>
Heating ...
<canvas id= "P" width= "height=" style= "Position:absolute; left:-999px" ></canvas>
<canvas id= "P2" width= "height=" "style=" Position:absolute; left:-999px "Top:-999px" >
<script>
var ctx = document.getElementById (' P '). GetContext (' 2d ');
var src = document.getElementById (' p2 ');

SetInterval (function () {
    for (var i=0; i<1000; i++)
        ctx.drawimage (src, 0, 0);
}, 16);
</script>
</body>



OK, simple code, but it does work and the fan starts to sound.
on IE9, the operation is exactly the same as imagined: CPU usage is less than 1%, and the page is minimized and still being rendered. The exact number of heat, but also have to master the boss.

At first it was only 40 degrees, and soon the temperature began to soar. Because it is an integrated graphics card, and the notebook hardware is relatively close, so the temperature is counted to the CPU ...



Of course, we can also use the worker to create multithreading, and then perform intensive operations, fully consume CPU resources ~
However, "heating" at the same time, in order not to affect the operation of other programs, so there is no waste of CPU.
Let's talk about it. The above code only works best in IE9.
There are still many browsers do not support HTML5 and worker threads, in order to make this "online heater" more compatible, the next time to do a flash version, the use of Stage3D accelerated GPU, as well as asynchronous shader consumes 100% of the CPU ...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.