summary refs log tree commit diff stats
path: root/lib/system/profiler.nim
Commit message (Expand)AuthorAgeFilesLines
* Enable embedded profiler to display filenames.Andrey Sobolev2016-08-021-6/+13
* prepare Nim codebase for upcoming parser changesAndreas Rumpf2016-07-151-1/+1
* modified the integrated profiler to hopefully produce more reliable resultsAndreas Rumpf2015-12-181-17/+9
* lib: Trim .nim files trailing whitespaceAdam Strzelecki2015-09-041-1/+1
* lib/system/g-w - Dropped 'T' from typespdw2015-06-041-10/+12
* Make ESTP compiledef2015-01-231-1/+1
* the big renamefest: first stepsAraq2014-08-221-2/+2
* Removes executable bit for text files.Grzegorz Adam Hankiewicz2013-03-161-0/+0
* first version of a memory profilerAraq2012-10-101-26/+43
* stricter symbol lookup in genericsAraq2012-09-171-4/+1
* profiler improvementsAraq2012-09-171-29/+13
* profiler documentationAraq2012-09-151-6/+0
* implemented a stack trace profilerAraq2012-09-151-47/+93
* year 2012 for most copyright headersAraq2012-01-021-1/+1
* fixed pango/pangoutils new wrappersAndreas Rumpf2010-02-261-0/+0
* continued work on html/xmlparserrumpf_a@web.de2010-02-141-0/+0
* bug concerning constant evaluation fixedAndreas Rumpf2009-11-261-4/+4
* added tools and web dirsAndreas Rumpf2009-09-151-0/+0
* version0.7.10Andreas Rumpf2009-06-081-0/+61
a@web.de> 2011-06-13 16:22:19 +0200 basic thread analysis working' href='/ahoang/Nim/commit/tests/accept/compile/tthreadanalysis.nim?h=devel&id=9f9f0f08187ebd5e83075960be7f24b087f5c6c4'>9f9f0f081 ^
e80465dac ^
9f9f0f081 ^











1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
           
                                         
          
                                                           



         
   
                                            
 
                          


                   
                         




















                                   
                                                        
             
                                  











                                                      
discard """
  errormsg: "'threadFunc' is not GC-safe"
  line: 38
  cmd: "nim $target --hints:on --threads:on $options $file"
"""

import os

var
  thr: array[0..5, Thread[tuple[a, b: int]]]

proc doNothing() = discard

type
  PNode = ref TNode
  TNode {.pure.} = object
    le, ri: PNode
    data: string

var
  root: PNode

proc buildTree(depth: int): PNode =
  if depth == 3: return nil
  new(result)
  result.le = buildTree(depth-1)
  result.ri = buildTree(depth-1)
  result.data = $depth

proc echoLeTree(n: PNode) =
  var it: PNode
  it = nil
  it = n
  while it != nil:
    echo it.data
    it = it.le

proc threadFunc(interval: tuple[a, b: int]) {.thread.} =
  doNothing()
  for i in interval.a..interval.b:
    var r = buildTree(i)
    echoLeTree(r) # for local data
  echoLeTree(root) # and the same for foreign data :-)

proc main =
  root = buildTree(5)
  for i in 0..high(thr):
    createThread(thr[i], threadFunc, (i*3, i*3+2))
  joinThreads(thr)

main()