summary refs log tree commit diff stats
path: root/svc/cache_test.go
Commit message (Collapse)AuthorAgeFilesLines
* license notice at top of each fileBen Morrison2019-07-111-0/+19
|
* changes related to registry-v0.3.0 v0.4.3Ben Morrison2019-06-181-1/+1
|
* updated cacheUpdate benchBen Morrison2019-06-131-1/+1
|
* temporarily disabling cacheUpdate testBen Morrison2019-06-121-0/+5
|
* more context to cacheUpdate test failureBen Morrison2019-06-121-1/+1
|
* cache.go tests finishedBen Morrison2019-06-111-8/+82
|
* updated cache benchmarksBen Morrison2019-06-111-0/+18
|
* eliminated confObj.LastCache and confObj.LastPush. Unneeded when using ↵Ben Morrison2019-06-111-18/+10
| | | | ticker for intervals.
* cache and db now use time.Ticker for events. refactored some initialization.Ben Morrison2019-06-111-49/+5
|
* cache-related testsBen Morrison2019-06-091-0/+53
|
* fixed some import commentsBen Morrison2019-06-051-1/+1
|
* moved bulk of code to its own package to clean up source treeBen Morrison2019-06-051-0/+32
olor: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
# Listing 7 of https://raytracing.github.io/books/RayTracingInOneWeekend.html
#
# To run (on Linux):
#   $ git clone https://github.com/akkartik/mu
#   $ cd mu
#   $ ./translate raytracing/2.mu
#   $ ./a.elf > 2.ppm

fn main -> _/ebx: int {
  print-string 0, "P3\n256 256\n255\n"
  var _four/edx: int <- copy 4
  var four/xmm1: float <- convert _four
  var one-fourth/xmm1: float <- reciprocal four
  var max/edx: int <- copy 0xff
  var image-size/xmm2: float <- convert max
  var j/ecx: int <- copy 0xff
  {
    compare j, 0
    break-if-<
    var i/eax: int <- copy 0
    {
      compare i, 0xff
      break-if->
      var c: rgb
      # compute r
      var tmp/xmm0: float <- convert i
      tmp <- divide image-size
      var r-addr/edx: (addr float) <- get c, r
      copy-to *r-addr, tmp
#?       var tmp2/ebx: int <- reinterpret *r-addr
#?       print-int32-hex 0, tmp2
#?       print-string 0, "\n"
      # compute g
      tmp <- convert j
      tmp <- divide image-size
      var g-addr/edx: (addr float) <- get c, g
      copy-to *g-addr, tmp
      # compute b
      var b-addr/edx: (addr float) <- get c, b
      copy-to *b-addr, one-fourth
      # emit
      var c-addr/edx: (addr rgb) <- address c
      print-rgb 0, c-addr
      i <- increment
      loop
    }
    j <- decrement
    loop
  }
  return 0
}

type rgb {
  # components normalized to within [0.0, 1.0]
  r: float
  g: float
  b: float
}

# print translating to [0, 256)
fn print-rgb screen: (addr screen), _c: (addr rgb) {
  var c/esi: (addr rgb) <- copy _c
  var n/ecx: int <- copy 0xff  # turns out 255 works just as well as 255.999, which is lucky because we don't have floating-point literals
  var xn/xmm1: float <- convert n
  # print 255 * c->r
  var result/xmm0: float <- copy xn
  var src-addr/eax: (addr float) <- get c, r
  result <- multiply *src-addr
  var result-int/edx: int <- convert result
  print-int32-decimal screen, result-int
  print-string screen, " "
  # print 255 * c->g
  src-addr <- get c, g
  result <- copy xn
  result <- multiply *src-addr
  result-int <- convert result
  print-int32-decimal screen, result-int
  print-string screen, " "
  # print 255 * c->b
  src-addr <- get c, b
  result <- copy xn
  result <- multiply *src-addr
  result-int <- convert result
  print-int32-decimal screen, result-int
  print-string screen, "\n"
}
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137