7730b6993f
- Create assembly/vm.ts with full RandomX VM implementation
- 256 instructions, 2048 iterations per hash
- Native u64/f64 operations in WebAssembly
- Full mode dataset lookups (2GB pre-computed)
- Update miner to use WASM VM for full mode
- mining-worker-asm.js uses pre-compiled WASM
- ~32 H/s per thread (4x faster than light mode)
- 8 threads achieves ~260 H/s
- Clean up redundant code
- Remove mining-worker-full.js (old JIT approach)
- Consolidate 'asm' mode into 'full' mode
40 lines
1.2 KiB
JavaScript
40 lines
1.2 KiB
JavaScript
/**
|
|
* Test the AssemblyScript-compiled VM
|
|
*/
|
|
|
|
import { createFullVM } from '../src/randomx/vm-full.js';
|
|
|
|
async function main() {
|
|
console.log('=== Full Mode VM Test ===\n');
|
|
|
|
// Create a small test dataset (just for testing)
|
|
const testDataset = new BigInt64Array(1000 * 8);
|
|
for (let i = 0; i < testDataset.length; i++) {
|
|
testDataset[i] = BigInt(i * 12345);
|
|
}
|
|
|
|
console.log('Creating VM...');
|
|
const vm = await createFullVM(testDataset);
|
|
console.log('VM created\n');
|
|
|
|
// Test hashing
|
|
const testInput = Buffer.from('test input for randomx hashing');
|
|
|
|
console.log('Computing hashes...');
|
|
const start = performance.now();
|
|
const numHashes = 5;
|
|
|
|
for (let i = 0; i < numHashes; i++) {
|
|
const input = Buffer.concat([testInput, Buffer.from([i])]);
|
|
const hash = vm.calculateHash(input);
|
|
console.log(`Hash ${i + 1}: ${Buffer.from(hash).toString('hex').substring(0, 32)}...`);
|
|
}
|
|
|
|
const elapsed = performance.now() - start;
|
|
console.log(`\n${numHashes} hashes in ${elapsed.toFixed(2)}ms`);
|
|
console.log(`Per hash: ${(elapsed / numHashes).toFixed(2)}ms`);
|
|
console.log(`Hashrate: ${(numHashes / (elapsed / 1000)).toFixed(2)} H/s`);
|
|
}
|
|
|
|
main().catch(console.error);
|