Esempio n. 1
0
        static void Main(string[] args)
        {
            var specHandle  = LibGrouper.LoadSpecification("hello/from/csharp");
            var total       = new Stopwatch();
            var assembling  = new Stopwatch();
            var serializing = new Stopwatch();
            var grouping    = new Stopwatch();
            var parsing     = new Stopwatch();

            var accum = 0;

            total.Start();
            for (int i = 0; i < 1_000_000; i++)
            {
                assembling.Start();
                var diagnoses = new List <PatientCase.Types.Diagnosis>(16);
                for (int j = 0; j < 10; j++)
                {
                    var diag = new PatientCase.Types.Diagnosis();
                    diag.Code = "DIAG" + j;

                    diagnoses.Add(diag);
                }

                var procedures = new List <PatientCase.Types.Procedure>(16);
                for (int j = 0; j < 10; j++)
                {
                    var proc = new PatientCase.Types.Procedure();
                    proc.Code = "PROC" + j;
                    proc.Date = 1 << 20;
                    proc.Side = PatientCase.Types.Procedure.Types.Side.B;

                    procedures.Add(proc);
                }

                var pc = new PatientCase();
                pc.Id        = "1337";
                pc.AgeYears  = 42;
                pc.AdmDate   = (1989 << 20 | 5 << 16 | 23 << 11);
                pc.SepDate   = (2019 << 20 | 6 << 16 | 27 << 11);
                pc.BirthDate = (1989 << 20 | 6 << 16 | 29 << 11);
                pc.Diagnoses.AddRange(diagnoses);
                pc.Procedures.AddRange(procedures);

                assembling.Stop();

                var result = LibGrouper.Group(pc, specHandle, grouping, parsing, serializing);
                accum += result.CalculateSize();
            }
            total.Stop();

            Console.WriteLine("Took {0}ms, {1}, Assembling: {2}ms, Serializing: {5}ms, Grouping: {3}ms, Parsing: {4}ms",
                              total.Elapsed.TotalMilliseconds,
                              accum,
                              assembling.Elapsed.TotalMilliseconds,
                              grouping.Elapsed.TotalMilliseconds,
                              parsing.Elapsed.TotalMilliseconds,
                              serializing.Elapsed.TotalMilliseconds
                              );
        }
Esempio n. 2
0
        public async Task <HttpResponseMessage> AddPatientCase(ApiModel inputmodel)
        {
            PatientCase data = new PatientCase();

            SoapCredential.UserName = AppSettings.GetByKey("USERNAME");
            SoapCredential.Password = AppSettings.GetByKey("PASSWORD");
            SoapCredential.Domain   = AppSettings.GetByKey("DOMAIN");

            try
            {
                ApiResponseModel <PatientCase> model = new ApiResponseModel <PatientCase>()
                {
                };
                var client = ServiceFactory.GetService(typeof(PatientCase));
                data = await client.addPatientCase(inputmodel.patientId, inputmodel.patientRecId, inputmodel.caseType, inputmodel.clinicId);

                model.data.records = data;
                return(Response.Success <PatientCase>(model));
            }
            catch (Exception ex)
            {
                return(Response.Exception(ex));
            }
        }
Esempio n. 3
0
        public static GroupResponse Group(PatientCase pc, long specHandle, Stopwatch grouping, Stopwatch parsing, Stopwatch serializing)
        {
            serializing.Start();
            var bytes = pc.ToByteArray();

            serializing.Stop();

            unsafe
            {
                fixed(byte *ptr = bytes)
                {
                    // Group
                    grouping.Start();
                    IntPtr resultPtr = NativeGroup((UIntPtr)ptr, (UIntPtr)bytes.Length, specHandle, out var resultLength);

                    grouping.Stop();

                    parsing.Start();
                    int checkedLen = (int)resultLength.ToUInt32();

                    // Copy from native to managed memory
                    byte[] buffer = new byte[checkedLen];
                    Marshal.Copy(resultPtr, buffer, 0, checkedLen);

                    // Free native memory
                    LibGrouper.FreeByteArray(resultPtr, resultLength);
                    // TODO [Perf] Find way to omit need for copy

                    // Parse
                    var parsed = GroupResponse.Parser.ParseFrom(buffer);

                    parsing.Stop();
                    return(parsed);
                }
            }
        }