Afficher la proportion de mémoire physique utilisée.

Contenu du snippet

<html
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:v="urn:schemas-microsoft-com:vml"
    xml:lang="en" lang="en">
  <head>
    <title>Memory usage</title>
    <style type="text/css">
/* <![CDATA[ */
h1 { text-align: center; margin-bottom: 100px; }
div#gr { text-align: center; }
v\:* { behavior: url(#default#VML); }
#pie {
	position: static;
	width: 200px; height: 200px;
}
#rcirc {
	position: absolute;
	left: -100; top: -100;
	width: 200; height: 200;
}
#bpath {
	position: absolute;
	left: -100; top: -100;
	width: 200; height: 200;
}
/* ]]> */
    </style>
    <script language="javascript" type="text/javascript">
// <![CDATA[
function set_pie(x)
{
	var a = Math.ceil(100 * Math.sin(x * 2 * Math.PI));
	var b = -Math.floor(100 * Math.cos(x * 2 * Math.PI));
	bpath.path = "ns m 0 0 wa -100 -100 100 100 0 -100 "
			+ a + " " + b + " x e";
}
var perf;
function get_mem_used()
{
	perf.Refresh_();
	return perf.FreePhysicalMemory / perf.TotalVisibleMemorySize;
}
function init()
{
	var loc = new ActiveXObject("WbemScripting.SWbemLocator");
	var wmi = loc.ConnectServer("", "root\\cimv2");
	var ins = wmi.InstancesOf("Win32_OperatingSystem");
	perf = (new Enumerator(ins)).item();
	set_pie(get_mem_used());
	window.setInterval("set_pie(get_mem_used())", 1000);
}
// ]]>
    </script>
  </head>
  <body onload="init()">
    <h1>Memory usage</h1>
    <div id="gr">
      <v:group id="pie" coordsize="200,200" coordorigin="-100,-100">
        <v:oval id="rcirc" fillcolor="red" strokecolor="black">
        </v:oval>
        <v:shape id="bpath" fillcolor="blue"
            path="ns m 0 0 wt -100 -100 100 100 0 -100 1 -100 x e">
        </v:shape>
      </v:group>
    </div>
  </body>
</html>

Compatibilité : Javascript

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.