This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
html, body { | |
width: 100%; | |
height: 100%; | |
margin: 0; | |
padding: 0 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as THREE from 'three'; | |
const scene = new THREE.Scene(); | |
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000); | |
const geometry = new THREE.BoxGeometry(); | |
const material = new THREE.MeshBasicMaterial({ color: 0x00ff00 }); | |
const cube = new THREE.Mesh(geometry, material); | |
let renderer; | |
scene.add(cube); | |
camera.position.z = 5; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
import { onMount } from 'svelte'; | |
import { createScene } from "./scene"; | |
let el; | |
onMount(() => { | |
createScene(el) | |
}); | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const windows = new Set(); | |
export const createWindow = async () => { | |
if ( | |
process.env.NODE_ENV === 'development' || | |
process.env.DEBUG_PROD === 'true' | |
) { | |
await installExtensions(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const t0 = performance.now(); | |
Math.log10(n) | |
const t1 = performance.now(); | |
console.log(`Call took ${t1 - t0} milliseconds.`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const runBaseline = (iterations = 100000000) => { | |
let startTime = new Date().getTime(); | |
for (let i = 0; i < iterations; i++) { | |
// no operation | |
} | |
let endTime = new Date().getTime(); | |
return endTime - startTime; | |
} | |
const runTest = (iterations = 100000000) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const runTest = (iterations = 100000000) => { | |
let startTime = new Date().getTime(); | |
for (let i = 0; i < iterations; i++) | |
Math.log10(0) | |
let endTime = new Date().getTime(); | |
let totalTime = endTime - startTime; | |
let fnTime = (totalTime / iterations).toFixed(10); | |
let operations = Math.floor(1000 / totalTime * iterations); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const runTest = (iterations = 100000000) => { | |
let startTime = new Date().getTime(); | |
for (let i = 0; i < iterations; i++) | |
Math.log10(0) | |
let endTime = new Date().getTime(); | |
let totalTime = endTime - startTime; | |
let fnTime = (totalTime / iterations).toFixed(10); | |
let operations = Math.floor(1000 / totalTime * iterations); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let iterations = 100000; | |
let startTime = new Date().getTime(); | |
for (let i = 0; i < iterations; i++) | |
Math.log10(0) | |
let endTime = new Date().getTime(); | |
let time = endTime - startTime; | |
console.info(`time: ${time}ms, op: ${time / iterations}ms`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Math.log10(n); | |
// Equivalent polyfill: | |
Math.log(n) * Math.LOG10E |