예제 #1
0
        /// <inheritdoc/>
        public override NameMapping GetMapping(int nameId)
        {
            lock (nameMappingCache) {
                if (nameMappingCache.ContainsKey(nameId))
                {
                    return(nameMappingCache[nameId]);
                }

                SQLiteCommand cmd;
                using (LockAndCreateCommand(out cmd)) {
                    cmd.CommandText = @"SELECT name, returntype, parameters
										FROM NameMapping
										WHERE id = "                                         + nameId + ";";

                    using (SQLiteDataReader reader = cmd.ExecuteReader()) {
                        string         name = null, returnType = null;
                        IList <string> parameters = null;

                        while (reader.Read())
                        {
                            name       = reader.GetString(0);
                            returnType = reader.GetString(1);
                            parameters = reader.GetString(2).Split('-').ToList();
                            if (parameters.Count == 1 && string.IsNullOrEmpty(parameters[0]))
                            {
                                parameters = new List <string>();
                            }
                        }

                        NameMapping map = new NameMapping(nameId, returnType, name, parameters);
                        nameMappingCache.Add(nameId, map);
                        return(map);
                    }
                }
            }
        }
		/// <inheritdoc/>
		public override NameMapping GetMapping(int nameId)
		{
			lock (nameMappingCache) {
				if (nameMappingCache.ContainsKey(nameId))
					return nameMappingCache[nameId];
				
				SQLiteCommand cmd;
				using (LockAndCreateCommand(out cmd)) {
					cmd.CommandText = @"SELECT name, returntype, parameters
										FROM NameMapping
										WHERE id = " + nameId + ";";
					
					using (SQLiteDataReader reader = cmd.ExecuteReader()) {
						
						string name = null, returnType = null;
						IList<string> parameters = null;
						
						while (reader.Read()) {
							name = reader.GetString(0);
							returnType = reader.GetString(1);
							parameters = reader.GetString(2).Split('-').ToList();
							if (parameters.Count == 1 && string.IsNullOrEmpty(parameters[0]))
								parameters = new List<string>();
						}
						
						NameMapping map = new NameMapping(nameId, returnType, name, parameters);
						nameMappingCache.Add(nameId, map);
						return map;
					}
				}
			}
		}
예제 #3
0
		public void FixtureSetUp()
		{
			if (File.Exists(databaseFileName))
				File.Delete(databaseFileName);
			NameMapping method0 = new NameMapping(0, "r0", "m0", new List<string>());
			NameMapping method1 = new NameMapping(1, "r1", "m1", new List<string>());
			NameMapping method2 = new NameMapping(2, "r2", "m2", new List<string>());
			using (var writer = new ProfilingDataSQLiteWriter(databaseFileName)) {
				writer.ProcessorFrequency = 2000; // MHz
				writer.WriteMappings(new[] { method0, method1, method2 } );
				CallTreeNodeStub dataSet;
				dataSet = new CallTreeNodeStub {
					NameMappingValue = method0,
					AddChildren = {
						new CallTreeNodeStub {
							NameMappingValue = method1,
							RawCallCountValue = 10,
							CpuCyclesSpentValue = 500 * k
						}
					}
				};
				writer.WriteDataSet(new DataSetStub { IsFirst = true, RootNode = dataSet });
				dataSet = new CallTreeNodeStub {
					NameMappingValue = method0,
					IsActiveAtStartValue = true,
					AddChildren = {
						new CallTreeNodeStub {
							NameMappingValue = method1,
							RawCallCountValue = 0,
							IsActiveAtStartValue = true,
							CpuCyclesSpentValue = 200 * k
						},
						new CallTreeNodeStub {
							NameMappingValue = method2,
							RawCallCountValue = 1,
							CpuCyclesSpentValue = 300 * k
						}
					}
				};
				writer.WriteDataSet(new DataSetStub { IsFirst = false, RootNode = dataSet });
				dataSet = new CallTreeNodeStub {
					NameMappingValue = method0,
					IsActiveAtStartValue = true,
					AddChildren = {
						new CallTreeNodeStub {
							NameMappingValue = method2,
							RawCallCountValue = 0,
							IsActiveAtStartValue = true,
							CpuCyclesSpentValue = 50 * k,
							AddChildren = {
								new CallTreeNodeStub {
									NameMappingValue = method1,
									RawCallCountValue = 5,
									CpuCyclesSpentValue = 1 * k
								}
							}
						}
					}
				};
				writer.WriteDataSet(new DataSetStub { IsFirst = false, RootNode = dataSet });
				writer.Close();
			}
			provider = ProfilingDataSQLiteProvider.UpgradeFromOldVersion(databaseFileName);
		}
 bool IsUnitTest(NameMapping name)
 {
     return(unitTestNames.Contains(name.Name));
 }
		bool IsUnitTest(NameMapping name)
		{
			return unitTestNames.Contains(name.Name);
		}