1<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> 2<html> 3<head> 4<title>Canvas 2d Context Font Property Speed</title> 5</head> 6<body> 7 <canvas id='thecanvas' height=100 width=100/> 8 <script> 9 var canvas = document.getElementById('thecanvas'); 10 var context = canvas.getContext('2d'); 11 var t0 = Date.now(); 12 for (var i = 0; i < 1000; i++) { 13 if(i % 2 == 0) 14 context.font = 'bold 13px Arial'; 15 else 16 context.font = 'italic 13px Arial'; 17 } 18 alert('Elapsed for 1000 font switches: ' + (Date.now() - t0)); 19 </script> 20</body> 21</html> 22