Пример #1
0
    // Start is called before the first frame update
    private void Start()
    {
        Debug.Log(Id);
        const int count   = 1;
        var       unique  = new Id64Generator(10);
        var       unique2 = new IdGuidGenerator(10);
        var       unique3 = new IdStringGeneratorWrapper(unique);

        Profiler.BeginSample("track snowflake 1");
        string str1 = "";

        for (int i = 0; i < count; i++)
        {
            str1 = unique.GenerateId().ToString();
        }

        Profiler.EndSample();

        Profiler.BeginSample("track snowflake 2");
        for (int i = 0; i < count; i++)
        {
            unique2.GenerateId();
        }

        Profiler.EndSample();

        Profiler.BeginSample("track snowflake 3");
        string str2 = "";

        for (int i = 0; i < count; i++)
        {
            str2 = unique3.GenerateId();
        }

        Profiler.EndSample();

        Profiler.BeginSample("track guid");
        for (int i = 0; i < count; i++)
        {
            Guid.NewGuid();
        }

        Profiler.EndSample();

        Debug.Log(str1);
        Debug.Log(str2);

        Main();
    }
Пример #2
0
        public void IdentiferUsesLowOrderBytesOfInt64()
        {
            long identifier = 0x0123456789abcdef;

            IIdGenerator<Guid> idGenerator = new IdGuidGenerator(identifier);

            Guid id = idGenerator.GenerateId();
            byte[] bytes = id.ToByteArray();

            Assert.AreEqual((byte)0x45, bytes[8 + 0]);
            Assert.AreEqual((byte)0x67, bytes[8 + 1]);
            Assert.AreEqual((byte)0x89, bytes[8 + 2]);
            Assert.AreEqual((byte)0xab, bytes[8 + 3]);
            Assert.AreEqual((byte)0xcd, bytes[8 + 4]);
            Assert.AreEqual((byte)0xef, bytes[8 + 5]);
        }
Пример #3
0
        public void IdentiferUsesLowOrderBytesOfInt64()
        {
            long identifier = 0x0123456789abcdef;

            IIdGenerator <Guid> idGenerator = new IdGuidGenerator(identifier);

            Guid id = idGenerator.GenerateId();

            byte[] bytes = id.ToByteArray();

            Assert.AreEqual((byte)0x45, bytes[8 + 0]);
            Assert.AreEqual((byte)0x67, bytes[8 + 1]);
            Assert.AreEqual((byte)0x89, bytes[8 + 2]);
            Assert.AreEqual((byte)0xab, bytes[8 + 3]);
            Assert.AreEqual((byte)0xcd, bytes[8 + 4]);
            Assert.AreEqual((byte)0xef, bytes[8 + 5]);
        }