Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Cleaning up

  • Loading branch information...
commit 00ab9af1abb8c98e57e0903aa65b272ec19322f2 1 parent 8358fb3
Paul Taysom authored
37 tau.pj/js.t/canvas.d/graph.js
@@ -56,11 +56,6 @@ Point.prototype = {
56 56
57 57 function Graph(n) {
58 58 this.values = [];
59   -/*
60   - for (var i = 0; i < n; i++) {
61   - this.addRandomValue();
62   - }
63   -*/
64 59 return graph;
65 60 }
66 61
@@ -108,8 +103,6 @@ Graph.prototype = {
108 103 }
109 104 ctx.stroke();
110 105 ctx.restore();
111   - /*
112   - */
113 106 }
114 107
115 108 function drawLine(xstart, ystart, xend, yend, color, width) {
@@ -142,7 +135,8 @@ Graph.prototype = {
142 135 var dtick = (mx.y - mn.y) / numYTicks;
143 136 var tick = dtick + mn.y;
144 137 for (var i = 0; i < numYTicks; i++) {
145   - label(Math.round(tick), leftMargin, yScale(tick));
  138 + label(Math.round(tick), leftMargin,
  139 + yScale(tick));
146 140 drawLine(mn.x, tick, mx.x, tick,
147 141 '#0F0', gridWidth);
148 142 tick += dtick;
@@ -152,11 +146,13 @@ Graph.prototype = {
152 146 function yAxis() {
153 147 yLabel('y axis');
154 148 drawLine(mn.x, mn.y, mn.x, mx.y, axisColor, axisWidth);
155   - label(Math.round(tick), xScale(tick), canvas.height - bottomMargin + 10);
  149 + label(Math.round(tick), xScale(tick),
  150 + canvas.height - bottomMargin + 10);
156 151 var dtick = (mx.x - mn.x) / numXTicks;
157 152 var tick = mn.x + dtick;
158 153 for (var i = 0; i < numXTicks; i++) {
159   - label(Math.round(tick), xScale(tick), canvas.height - bottomMargin + 10);
  154 + label(Math.round(tick), xScale(tick),
  155 + canvas.height - bottomMargin + 10);
160 156 drawLine(tick, mn.y, tick, mx.y,
161 157 '#0F0', gridWidth);
162 158 tick += dtick;
@@ -167,7 +163,8 @@ Graph.prototype = {
167 163 ctx.save();
168 164 ctx.strokeStyle = '#0F0';
169 165 ctx.lineWidth = 1;
170   - ctx.strokeText(text, canvas.width / 2, canvas.height - bottomMargin / 2);
  166 + ctx.strokeText(text, canvas.width / 2,
  167 + canvas.height - bottomMargin / 2);
171 168 ctx.restore();
172 169 }
173 170
@@ -207,8 +204,6 @@ function pickAplot() {
207 204 }
208 205
209 206 function step() {
210   -// graph.addRandomValue();
211   -// graph.draw();
212 207 $.get(thePlot, handleResponse);
213 208 }
214 209
@@ -237,13 +232,6 @@ function run() {
237 232
238 233 pickAplot();
239 234
240   -/*
241   - $('body').click(function(e) {
242   - g.push(Math.random() * 1000); // g = genGraph(100);
243   - drawGraph(g);
244   - });
245   -*/
246   -
247 235 resume();
248 236 }
249 237
@@ -268,13 +256,4 @@ function handleResponse(response) {
268 256 }
269 257 }
270 258
271   -function plot() {
272   - canvas = $('#canvas').get(0);
273   - ctx = canvas.getContext('2d');
274   -
275   - $.get("data", handleResponse);
276   -}
277   -
278   -//$(plot);
279   -
280 259 })();
83 tau.pj/tests.t/play.m/hist.c
... ... @@ -0,0 +1,83 @@
  1 +/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
  2 + * Use of this source code is governed by a BSD-style license that can be
  3 + * found in the LICENSE file.
  4 + */
  5 +#include <stdio.h>
  6 +#include <stdlib.h>
  7 +
  8 +#include <debug.h>
  9 +#include <eprintf.h>
  10 +#include <puny.h>
  11 +#include <style.h>
  12 +#include <timer.h>
  13 +#include <twister.h>
  14 +
  15 +/* test pseudo-random number generators */
  16 +
  17 +typedef u64 (*rnd_f)(void);
  18 +
  19 +static void timer (char *name, rnd_f rnd)
  20 +{
  21 + u64 start;
  22 + u64 finish;
  23 + u64 sum = 0;
  24 + unint i = Option.iterations;
  25 +
  26 + start = nsecs();
  27 + while (i--) {
  28 + sum += rnd();
  29 + }
  30 + finish = nsecs();
  31 + printf("%-20s: %g nsecs/rnd sum=%lld\n",
  32 + name,
  33 + (double)(finish - start) / (double)Option.iterations,
  34 + sum);
  35 +}
  36 +
  37 +#define TIMER(_rng) { \
  38 + u64 start; \
  39 + u64 finish; \
  40 + u64 sum = 0; \
  41 + unint i = Option.iterations; \
  42 + \
  43 + start = nsecs(); \
  44 + while (i--) { \
  45 + sum += _rng; \
  46 + } \
  47 + finish = nsecs(); \
  48 + printf("%-20s: %g nsecs/rnd sum=%lld\n", \
  49 + # _rng, \
  50 + (double)(finish - start) / (double)Option.iterations, \
  51 + sum); \
  52 +}
  53 +
  54 +
  55 +int main (int argc, char *argv[])
  56 +{
  57 +#if 0
  58 + unsigned long long init[4]={0x12345ULL, 0x23456ULL,
  59 + 0x34567ULL, 0x45678ULL}, length=4;
  60 + init_by_array64(init, length);
  61 +#endif
  62 + Twister_s twister;
  63 + int i;
  64 +
  65 + punyopt(argc, argv, NULL, NULL);
  66 + TIMER(rand());
  67 + TIMER(random());
  68 + TIMER(twister_random());
  69 + TIMER(twister_random());
  70 + timer("rand", (rnd_f)rand);
  71 + timer("random", (rnd_f)random);
  72 + timer("twister_random", (rnd_f)twister_random);
  73 + TIMER(rand());
  74 + TIMER(random());
  75 + TIMER(twister_random());
  76 + for (i = 0; i < Option.numthreads; i++) {
  77 + init_twister_r(17, &twister);
  78 + TIMER(twister_random_r(&twister));
  79 + }
  80 + init_twister_r(17, &twister);
  81 + TIMER(twister_random_r(&twister));
  82 + return 0;
  83 +}
4 tau.pj/tests.t/play.m/prefix.c
@@ -57,7 +57,7 @@ Lump_s prefix(Lump_s a, Lump_s b) {
57 57 size = a.size;
58 58 }
59 59 for (i = 0; i < size; i++) {
60   - if (a.d[i] != b.d[i]) {
  60 + if (((u8 *)a.d)[i] != ((u8 *)b.d)[i]) {
61 61 ++i;
62 62 break;
63 63 }
@@ -67,7 +67,7 @@ Lump_s prefix(Lump_s a, Lump_s b) {
67 67 return p;
68 68 }
69 69
70   -#define LUMP(_x) (_x).size, (_x).d
  70 +#define LUMP(_x) (_x).size, ((u8 *)(_x).d)
71 71 int main (int argc, char *argv[]) {
72 72 Lump_s a;
73 73 Lump_s b;

0 comments on commit 00ab9af

Please sign in to comment.
Something went wrong with that request. Please try again.