Skip to content

Instantly share code, notes, and snippets.

View mraleph's full-sized avatar
🐌

Slava Egorov mraleph

🐌
View GitHub Profile

"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

#include <stdint.h>
/* clang version 3.5.0 (trunk 214024) */
void f(uint32_t* p) {
while (__builtin_uadd_overflow(*p, 1, p)) {
p++;
}
}
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.
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
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;
function foo(x) {
function getCapacity(smth) {
}
this.x = function () {
getCapacity(yyy);
};
return this;
}

new Fn(...) vs Object.create(P)

Basics of object layout in V8

Each JavaScript object in V8 looks like this

+-------+
|  map  | -> pointer to the hidden class
+-------+
function B1() {
/* Benchmark.prototype.setup goes here {{{ */
var arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
seed_data = 3,
result = 0;
/* }}} */
var start = new Date;
while (...) { /* do N iterations of test body */
/* body of the case goes here {{{ */
for (var i = 0; i < arr1.length; i++) {
~ ∮ dig cdnjs.com AAAA +short
2400:cb00:2048:1::a29f:f729
2400:cb00:2048:1::a29f:f829
~ ∮ curl -m 20 -v -o /dev/null -s -w "got %{size_download} bytes." -g --header 'Host: cdnjs.com' 'http://[2400:cb00:2048:1::a29f:f829]/'
* About to connect() to 2400:cb00:2048:1::a29f:f829 port 80 (#0)
* Trying 2400:cb00:2048:1::a29f:f829... connected
> GET / HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Accept: */*
> Host: cdnjs.com
diff --git a/web/fc-app.dart b/web/fc-app.dart
index 9ab1b10..f8982d3 100644
--- a/web/fc-app.dart
+++ b/web/fc-app.dart
@@ -1,11 +1,30 @@
import "package:polymer/polymer.dart";
import "dart:html";
-import "dart:js";