Ejemplo n.º 1
0
    /// <summary>
    /// An example of a function that would be placed in an event class
    /// </summary>
    void ExampleWriter()
    {
        //Simply creates the dummy class containing arbitrary values
        dummy d = new dummy();

        ////Creates a new point with a preset measurement (database)
        Point p = new Point("dummy_metric");

        //At least one tag must be used, but you can use as many as you wish
        //Tags are used for easier querying in the Influx database
        p.addTag("AIname", d.name);
        p.addTag("host", "unity5.6");

        //At least one field must be used, but you can use as many as you wish
        //Fields are used to store values that you want to be stored in the Influx database
        p.addField("valueOne", d.values[0]);
        p.addField("valueTwo", d.values[1]);
        p.addField("age", d.age);
        p.addField("isFemale", d.isFemale);

        //Adding timestamps are optional, as the Influx database autogenerates(server time, which need to be noted) them if they are not given during transmit
        p.addTimestamp(System.DateTime.UtcNow);

        //Transmits all stored data to the Influx database.
        influx.writeMeasurment(GetComponent <MonoBehaviour>(), p);
    }
Ejemplo n.º 2
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        dummy Dummy = collision.gameObject.GetComponent <dummy>();

        if (Dummy != null)
        {
            Destroy(collision.gameObject);
        }
    }
Ejemplo n.º 3
0
        public static Button(uint id, dummy execute, dummy end)   // to assign to button, cannot take or return values.
        {
            buttonID = id;
            toDo     = execute;
            onStop   = end;

            if (controller == null)
            {
                controller = new GameController(UsbHostDevice.GetInstance());
            }                                                                                        // Create controller.
        }
Ejemplo n.º 4
0
 void delay()
 {
     dothis = () => {
         ParseUser.CurrentUser.SaveAsync().ContinueWith(t =>
                                                        {
             // Now let's update it with some new data.  In this case, only cheatMode
             // and score will get sent to the cloud.  playerName hasn't changed.
             //ParseUser.CurrentUser["Geolocation"] =  new ParseGeoPoint( 50, 50 );
             ParseUser.CurrentUser.SaveAsync();
         });
         StartCoroutine(wait (2, dothis));
     };
 }
Ejemplo n.º 5
0
            public virtual global::Grpc.Core.AsyncUnaryCall <global::Bond.Grpc.IMessage <dummy> > foo44Async(dummy request, global::Grpc.Core.Metadata headers = null, global::System.DateTime?deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
            {
                var message = global::Bond.Grpc.Message.From(request);

                return(foo44Async(message, new global::Grpc.Core.CallOptions(headers, deadline, cancellationToken)));
            }
Ejemplo n.º 6
0
        public void foo14Async(dummy param)
        {
            var message = new global::Bond.Comm.Message <dummy>(param);

            foo14Async(message);
        }
Ejemplo n.º 7
0
        public global::System.Threading.Tasks.Task <global::Bond.Comm.IMessage <dummy> > foo44Async(dummy param)
        {
            var message = new global::Bond.Comm.Message <dummy>(param);

            return(foo44Async(message, global::System.Threading.CancellationToken.None));
        }
Ejemplo n.º 8
0
        public void VarSizes_Increasing_Random(bool isParallel, int cnt, int minSz, int maxSz, bool speed, bool rnd)
        {
            using (var pile = new DefaultPile())
            {
              pile.Start();
              pile.AllocMode = speed ? AllocationMode.FavorSpeed : AllocationMode.ReuseSpace;

              var sw = Stopwatch.StartNew();
              var tasks = new List<Task>();
              for(var t=0; t < (isParallel? (System.Environment.ProcessorCount - 1) : 1); t++)
               tasks.Add(
                  Task.Run( () =>
                  {
                     var dict = new Dictionary<PilePointer, dummy>();
                     var lst = new List<PilePointer>();
                     var priorOdd = PilePointer.Invalid;
                     for(var i=0; i<cnt; i++)
                     {
                       var buf = new byte[12 +
                                          minSz+
                                          (
                                          rnd
                                           ? (NFX.ExternalRandomGenerator.Instance.NextScaledRandomInteger(0, (int)(maxSz*(i/(double)cnt))))
                                           : (int)(maxSz*(i/(double)cnt))
                                          )
                                         ];
                       var data = new dummy{ bin = buf};
                       data.bin.WriteBEInt32(0, ExternalRandomGenerator.Instance.NextRandomInteger);
                       data.bin.WriteBEInt32(data.bin.Length-4, ExternalRandomGenerator.Instance.NextRandomInteger);
                       var ptr = pile.Put(data);
                       Assert.IsTrue( ptr.Valid );

                       dict.Add(ptr, data);
                       lst.Add(ptr);

                       if (i>cnt/3)
                       {
                         if (ExternalRandomGenerator.Instance.NextRandomInteger > 0)
                         {
                           var ri = ExternalRandomGenerator.Instance.NextScaledRandomInteger(0, lst.Count-1);
                           var pp = lst[ri];
                           if (!pp.Valid) continue;

                           Assert.IsTrue( pile.Delete(pp) );
                           dict.Remove( pp );
                           lst[ri] = PilePointer.Invalid;

                         }
                       }

                       if (i%1000==0)
                        Console.WriteLine("Thread{0} did {1}; allocated {2} bytes, utilized {3} bytes by {4} objects {5} bytes/obj. ",
                                          Thread.CurrentThread.ManagedThreadId,
                                           i,
                                           pile.AllocatedMemoryBytes,
                                           pile.UtilizedBytes,
                                           pile.ObjectCount,
                                           pile.UtilizedBytes / pile.ObjectCount);

                     }
                     Console.WriteLine("Thread {0} Population done, now checking the buffers... {1}",Thread.CurrentThread.ManagedThreadId, DateTime.Now);

                     foreach(var entry in dict)
                       Assert.IsTrue( NFX.IOMiscUtils.MemBufferEquals(entry.Value.bin, (pile.Get(entry.Key) as dummy).bin));

                     Console.WriteLine("Thread {0} DONE. {1}", Thread.CurrentThread.ManagedThreadId, DateTime.Now);
                  })
            );//add

              Task.WaitAll( tasks.ToArray() );
              var el = sw.ElapsedMilliseconds;
              var gt = cnt * tasks.Count;
              Console.WriteLine("Total objects: {0:n0} in {1:n0} ms at {2:n0} obj/sec".Args(gt, el, gt / (el / 1000d)));
            }
        }
Ejemplo n.º 9
0
        public void VarSizes_Checkboard(bool isParallel, int cnt, int minSz, int maxSz, bool speed)
        {
            using (var pile = new DefaultPile())
            {
              pile.Start();
              pile.AllocMode = speed ? AllocationMode.FavorSpeed : AllocationMode.ReuseSpace;

              var tasks = new List<Task>();
              for(var t=0; t < (isParallel? (System.Environment.ProcessorCount - 1) : 1); t++)
               tasks.Add(
                  Task.Run( () =>
                  {
                     var dict = new Dictionary<PilePointer, dummy>();
                     var priorOdd = PilePointer.Invalid;
                     for(var i=0; i<cnt; i++)
                     {
                       var even = (i&0x01)==0;
                       var data = new dummy{ bin = new byte[12 + NFX.ExternalRandomGenerator.Instance.NextScaledRandomInteger(minSz, maxSz)]};
                       data.bin.WriteBEInt32(0, ExternalRandomGenerator.Instance.NextRandomInteger);
                       data.bin.WriteBEInt32(data.bin.Length-4, ExternalRandomGenerator.Instance.NextRandomInteger);
                       var ptr = pile.Put(data);
                       Assert.IsTrue( ptr.Valid );

                       if (even)
                        dict.Add(ptr, data);
                       else
                       {
                        if (priorOdd.Valid)
                         Assert.IsTrue( pile.Delete(priorOdd) );
                        priorOdd = ptr;
                       }

                       if (i%1000==0)
                        Console.WriteLine("Thread{0} did {1}; allocated {2} bytes, utilized {3} bytes by {4} objects {5} bytes/obj. ",
                                          Thread.CurrentThread.ManagedThreadId,
                                           i,
                                           pile.AllocatedMemoryBytes,
                                           pile.UtilizedBytes,
                                           pile.ObjectCount,
                                           pile.UtilizedBytes / pile.ObjectCount);

                     }
                     Console.WriteLine("Thread {0} Population done, now checking the buffers... {1}",Thread.CurrentThread.ManagedThreadId, DateTime.Now);

                     foreach(var entry in dict)
                       Assert.IsTrue( NFX.IOMiscUtils.MemBufferEquals(entry.Value.bin, (pile.Get(entry.Key) as dummy).bin));

                     Console.WriteLine("Thread {0} DONE. {1}", Thread.CurrentThread.ManagedThreadId, DateTime.Now);
                  })
            );//add

              Task.WaitAll( tasks.ToArray() );
            }
        }
Ejemplo n.º 10
0
        public void VarSizes_Increasing_Random(bool isParallel, int cnt, int minSz, int maxSz, bool speed, bool rnd)
        {
            using (var pile = new DefaultPile())
            {
                pile.Start();
                pile.AllocMode = speed ? AllocationMode.FavorSpeed : AllocationMode.ReuseSpace;

                var sw    = Stopwatch.StartNew();
                var tasks = new List <Task>();
                for (var t = 0; t < (isParallel? (System.Environment.ProcessorCount - 1) : 1); t++)
                {
                    tasks.Add(
                        Task.Run(() =>
                    {
                        var dict     = new Dictionary <PilePointer, dummy>();
                        var lst      = new List <PilePointer>();
                        var priorOdd = PilePointer.Invalid;
                        for (var i = 0; i < cnt; i++)
                        {
                            var buf = new byte[12 +
                                               minSz +
                                               (
                                                   rnd
                                           ? (NFX.ExternalRandomGenerator.Instance.NextScaledRandomInteger(0, (int)(maxSz * (i / (double)cnt))))
                                           : (int)(maxSz * (i / (double)cnt))
                                               )
                                      ];
                            var data = new dummy {
                                bin = buf
                            };
                            data.bin.WriteBEInt32(0, ExternalRandomGenerator.Instance.NextRandomInteger);
                            data.bin.WriteBEInt32(data.bin.Length - 4, ExternalRandomGenerator.Instance.NextRandomInteger);
                            var ptr = pile.Put(data);
                            Assert.IsTrue(ptr.Valid);

                            dict.Add(ptr, data);
                            lst.Add(ptr);

                            if (i > cnt / 3)
                            {
                                if (ExternalRandomGenerator.Instance.NextRandomInteger > 0)
                                {
                                    var ri = ExternalRandomGenerator.Instance.NextScaledRandomInteger(0, lst.Count - 1);
                                    var pp = lst[ri];
                                    if (!pp.Valid)
                                    {
                                        continue;
                                    }

                                    Assert.IsTrue(pile.Delete(pp));
                                    dict.Remove(pp);
                                    lst[ri] = PilePointer.Invalid;
                                }
                            }


                            if (i % 1000 == 0)
                            {
                                Console.WriteLine("Thread{0} did {1}; allocated {2} bytes, utilized {3} bytes by {4} objects {5} bytes/obj. ",
                                                  Thread.CurrentThread.ManagedThreadId,
                                                  i,
                                                  pile.AllocatedMemoryBytes,
                                                  pile.UtilizedBytes,
                                                  pile.ObjectCount,
                                                  pile.UtilizedBytes / pile.ObjectCount);
                            }
                        }
                        Console.WriteLine("Thread {0} Population done, now checking the buffers... {1}", Thread.CurrentThread.ManagedThreadId, DateTime.Now);

                        foreach (var entry in dict)
                        {
                            Assert.IsTrue(NFX.IOMiscUtils.MemBufferEquals(entry.Value.bin, (pile.Get(entry.Key) as dummy).bin));
                        }

                        Console.WriteLine("Thread {0} DONE. {1}", Thread.CurrentThread.ManagedThreadId, DateTime.Now);
                    })
                        );//add
                }
                Task.WaitAll(tasks.ToArray());
                var el = sw.ElapsedMilliseconds;
                var gt = cnt * tasks.Count;
                Console.WriteLine("Total objects: {0:n0} in {1:n0} ms at {2:n0} obj/sec".Args(gt, el, gt / (el / 1000d)));
            }
        }
Ejemplo n.º 11
0
        public void VarSizes_Checkboard(bool isParallel, int cnt, int minSz, int maxSz, bool speed)
        {
            using (var pile = new DefaultPile())
            {
                pile.Start();
                pile.AllocMode = speed ? AllocationMode.FavorSpeed : AllocationMode.ReuseSpace;

                var tasks = new List <Task>();
                for (var t = 0; t < (isParallel? (System.Environment.ProcessorCount - 1) : 1); t++)
                {
                    tasks.Add(
                        Task.Run(() =>
                    {
                        var dict     = new Dictionary <PilePointer, dummy>();
                        var priorOdd = PilePointer.Invalid;
                        for (var i = 0; i < cnt; i++)
                        {
                            var even = (i & 0x01) == 0;
                            var data = new dummy {
                                bin = new byte[12 + NFX.ExternalRandomGenerator.Instance.NextScaledRandomInteger(minSz, maxSz)]
                            };
                            data.bin.WriteBEInt32(0, ExternalRandomGenerator.Instance.NextRandomInteger);
                            data.bin.WriteBEInt32(data.bin.Length - 4, ExternalRandomGenerator.Instance.NextRandomInteger);
                            var ptr = pile.Put(data);
                            Assert.IsTrue(ptr.Valid);

                            if (even)
                            {
                                dict.Add(ptr, data);
                            }
                            else
                            {
                                if (priorOdd.Valid)
                                {
                                    Assert.IsTrue(pile.Delete(priorOdd));
                                }
                                priorOdd = ptr;
                            }


                            if (i % 1000 == 0)
                            {
                                Console.WriteLine("Thread{0} did {1}; allocated {2} bytes, utilized {3} bytes by {4} objects {5} bytes/obj. ",
                                                  Thread.CurrentThread.ManagedThreadId,
                                                  i,
                                                  pile.AllocatedMemoryBytes,
                                                  pile.UtilizedBytes,
                                                  pile.ObjectCount,
                                                  pile.UtilizedBytes / pile.ObjectCount);
                            }
                        }
                        Console.WriteLine("Thread {0} Population done, now checking the buffers... {1}", Thread.CurrentThread.ManagedThreadId, DateTime.Now);

                        foreach (var entry in dict)
                        {
                            Assert.IsTrue(NFX.IOMiscUtils.MemBufferEquals(entry.Value.bin, (pile.Get(entry.Key) as dummy).bin));
                        }

                        Console.WriteLine("Thread {0} DONE. {1}", Thread.CurrentThread.ManagedThreadId, DateTime.Now);
                    })
                        );//add
                }
                Task.WaitAll(tasks.ToArray());
            }
        }
Ejemplo n.º 12
0
 IEnumerator wait(float sec, dummy dothis)
 {
     yield return new WaitForSeconds (sec);
     dothis ();
 }
Ejemplo n.º 13
0
 private void updateClientTree(string nick, bool add)
 {
     int exists = clientExists(nick);
     if (exists < 0 && add)
     {
         dummy dummy = new dummy(nick);
         dummy.x = 10;
         dummy.y = 30;
         dummy.z = 10;
         clients.Add(dummy);
     }
     else if (exists >= 0 && !add)
     {
         clients.RemoveAt(exists);
     }
 }