Skip to content

Instantly share code, notes, and snippets.

View robertleeplummerjr's full-sized avatar

Robert Plummer robertleeplummerjr

View GitHub Profile
sudo apt-get install -y build-essential libxi-dev libglu1-mesa-dev libglew-dev pkg-config xvfb nodejs npm
const benchmark = require('./src/index'),
fs = require('fs');
const out = benchmark.multipleBenchmark({
commonOptions: {
cpu_benchmark: true,
num_benchmarks: 5
},
range: {
optionName: 'matrix_size',
@robertleeplummerjr
robertleeplummerjr / migrate-assert-to-expect.js
Created August 14, 2019 10:30
A script that migrates from using assert to jest's expect
const { parse } = require('acorn');
const fs = require('fs');
const file = fs.readFileSync('./__tests__/file-name.js').toString();
const rootAST = parse(file, {
locations: true
});
function traverse(ast) {
if (Array.isArray(ast)) {
for (let i = 0; i < ast.length; i++) {
// taken from examples at gpu.js: https://github.com/gpujs/gpu.js/blob/develop/examples/mandelbrot-set.html
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { GLView } from 'expo-gl';
import { GPU } from '@gpujs/expo-gl';
export default function App() {
createKernel();
return (
function kernel(context = null) {
const gl = context;
const glVariables0 = gl.getExtension('OES_texture_float');
const glVariables1 = gl.getExtension('OES_texture_float_linear');
const glVariables2 = gl.getExtension('OES_element_index_uint');
const glVariables3 = gl.getExtension('WEBGL_draw_buffers');
const glVariables4 = gl.getExtension('WEBGL_color_buffer_float');
const glVariable5 = gl.createTexture();
const glVariable6 = gl.createTexture();
gl.enable(gl.SCISSOR_TEST);
float getMemoryOptimized32(sampler2D tex, ivec2 texSize, ivec3 texDim, int z, int y, int x) {
ivec3 xyz = ivec3(x, y, z);
__GET_WRAPAROUND__;
int index = xyz.x + texDim.x * (xyz.y + texDim.y * xyz.z);
int channel = integerMod(index, 4);
index = index / 4;
int w = texSize.x;
vec2 st = vec2(float(integerMod(index, w)), float(index / w)) + 0.5;
vec4 texel = texture2D(tex, st / vec2(texSize));
if (channel == 0) return texel.r;
const { GPU } = require('gpu.js');
const gpu = new GPU({ mode: 'gpu' });
for (let i = 0; i < 1000; i++) { //1000 seems... so small...
const setup = setupBenchmark(i * 512);
benchmark(setup);
}
function setupBenchmark(size) {
<html>
<body>
<canvas></canvas>
</body>
<script>
const canvas = document.querySelector('canvas');
const gl = canvas.getContext('webgl2', {
alpha: false,
depth: false,
antialias: false
<html>
<body>
<canvas></canvas>
</body>
<script>
const canvas = document.querySelector('canvas');
const gl = canvas.getContext('webgl2', {
alpha: false,
depth: false,
antialias: false
<html>
<body>
<canvas></canvas>
</body>
<script>
const canvas = document.querySelector('canvas');
const gl = canvas.getContext('webgl2', {
alpha: false,
depth: false,
antialias: false