Skip to content

Instantly share code, notes, and snippets.

View mraleph's full-sized avatar
🐌

Slava Egorov mraleph

🐌
View GitHub Profile
diff --git a/Dart_RaytracerDemo/web/SimpleRaytracer.dart b/Dart_RaytracerDemo/web/SimpleRaytracer.dart
index d02b6f7..458394b 100644
--- a/Dart_RaytracerDemo/web/SimpleRaytracer.dart
+++ b/Dart_RaytracerDemo/web/SimpleRaytracer.dart
@@ -34,9 +34,9 @@ import "dart:async";
import "missing.dart";
class Vector3f {
- double x=0.0, y=0.0, z=0.0;
+ double x, y, z;
Samples: 22K of event 'cycles', Event count (approx.): 18909447319
Overhead Command Shared Object Symbol ◆
+ 17.39% d8 perf-30177.map [.] LazyCompile:ToString native runtime.js:328 ▒
+ 15.51% d8 perf-30177.map [.] Stub:CompareICStub ▒
+ 11.63% d8 perf-30177.map [.] LazyCompile:*a native array.js:621
function B1() {
var start = Date.now();
while (...) { /* do N iterations of test body */
/* body of the case goes here {{{ */
function X() { return "hello"; }
// Strictly speaking you can't have FunctionDeclaration as a Statement (see http://es5.github.io/#x12)
// However most implementations support this for compatibility reasons.
// V8 for example hoists all FunctionDeclarations to the top level, just like it does with variable
// declarations. This means in this case X is *not* created again and again everytime the loop is entered.
// Essentially this loop becomes empty.
#include <stdint.h>
/* clang version 3.5.0 (trunk 214024) */
void f(uint32_t* p) {
while (__builtin_uadd_overflow(*p, 1, p)) {
p++;
}
}

"A survey of the literature on optimization uncovers many techniques that are hard to understand, harder to implement, more general than necessary and of marginal value. Our approach was to do the most profitable machine independent optimizations in the most profitable way"

Michael L. Powel - A Portable Optimizing Compiler for Modula-2

@mraleph
mraleph / test.cc
Last active August 29, 2015 14:08
#include <cstdio>
#include <stdint.h>
struct value_t {
union {
float fx[2];
int32_t ix[2];
};
@mraleph
mraleph / writer.dart
Last active May 5, 2025 14:00
manual big endian conversion in Dart
library writer;
import 'dart:typed_data';
/// Writer wraps a fixed size Uint8List and writes values into it using
/// big-endian byte order.
class Writer {
/// Output buffer.
final Uint8List out;
// Benefit of optimizing this function via OSR is high:
// a) it is long running;
// b) optimization speeds up the code considerably;
// c) it is called a few times only.
function loopy() {
var arr = new Uint8Array(100);
for (var j = arr[0]; j < 1e2; j++) {
for (var i = arr[0]; i < 1e6; i++) {
Math.sqrt(arr[0] * arr[0]);
}
function f(x, y) {
x = 'Q: why?';
console.log(arguments[0]);
arguments[1] = 'A: just because';
console.log(y);
}
f(null, null);
// Q: why?
// A: just because
$ node -e "console.log(process.versions.v8)"
3.14.5.9
$ node bubble.js
81754
$ iojs -e "console.log(process.versions.v8)"
4.1.0.7
$ iojs bubble.js
42165
$ diff -u bubble.js bubble1.js
--- bubble.js 2015-03-04 20:41:08.432717779 +0100