小编Vla*_*den的帖子

嵌套并行性能问题

我有问题.

在另一个Parallel.ForEach中使用Parallel.Invoke有什么好处吗?

这是我的代码:

    Parallel.ForEach(yearMonths,
                     () => new List<DJVSStatsCo>(),
                     (yearMonth, loopState, localDjvsStatsCo) =>
                         {
                             var coVintageCounter = 0;
                             var coExitsCounter = 0;
                             var coExtant = 0;

                             Parallel.Invoke(() =>
                                             coVintageCounter = globalData.ValuationEventsPit.
                                                                    Where(x => x.FirstRoundYearMonth <= yearMonth).
                                                                    Select(x => x.CompanyId).Distinct().Count(),
                                             () =>
                                             coExitsCounter = globalData.ValuationEventsPit.
                                                                  Where(x => x.ExitDate != null && x.ExitDateYearMonth == yearMonth).
                                                                  Select(x => x.CompanyId).Distinct().Count(),
                                             () =>
                                             coExtant = globalData.ValuationEventsPit.
                                                            Where(x => x.FirstRoundYearMonth <= yearMonth && (x.ExitDate == null || x.ExitDateYearMonth > yearMonth)).
                                                            Select(x => x.CompanyId).Distinct().Count()
                                 );

                             localDjvsStatsCo.Add(new DJVSStatsCo(yearMonth, coVintageCounter, …
Run Code Online (Sandbox Code Playgroud)

.net c# parallel-processing multithreading task-parallel-library

4
推荐指数
1
解决办法
903
查看次数

WCF IIS服务器配置

我有带有IIS7的Windows Server 2008 R2.我在上面部署了WCF服务.当我在浏览器(本地或外部机器)中指定WCF服务地址时http://sbkisourcedev01/VCIndex/Calculator.svc?wsdl我在浏览器中获取服务描述.但是,当我尝试将该项目的引用添加到该服务时,我收到以下错误:

The document was understood, but it could not be processed.  

  - The WSDL document contains links that could not be resolved.
  - There was an error downloading 'http://sbkisourcedev01/VCIndex/Calculator.svc?xsd=xsd0'.
  - The underlying connection was closed: An unexpected error occurred on a receive.
  - Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
  - An existing connection was forcibly closed by the remote host

Metadata contains a …

iis configuration wcf iis-7 web-config

2
推荐指数
1
解决办法
7811
查看次数

LINQ左外连接语法差异

在LINQ中至少有两种方法可以进行LEFT OUTER JOIN

class Customer
{
    public int ID { get; set; }
    public string Name { get; set; }
}

class Order
{
    public int ID { get; set; }
    public string Product { get; set; }
}

    static void Main()
    {
        // Example customers.
        var customers = new Customer[]
        {
            new Customer{ID = 5, Name = "Sam"},
            new Customer{ID = 6, Name = "Dave"},
            new Customer{ID = 7, Name = "Julia"},
            new Customer{ID = 8, Name = "Sue"}, …
Run Code Online (Sandbox Code Playgroud)

c# linq linq-to-objects join left-join

2
推荐指数
1
解决办法
8114
查看次数

每次在Python中运行代码时,如何以相同的顺序随机化pandas列?

这是我的代码:

random_idx = np.random.permutation(len(cIds))
train_Ids = cIds[random_idx[:train_size]]
Run Code Online (Sandbox Code Playgroud)

现在,我希望每次运行这行代码时,列表都以相同的顺序随机化.

注意:我不想random_idx在文本文件中保存变量,并获取相同的列表.

python random numpy pandas

2
推荐指数
1
解决办法
58
查看次数

从数据库中获取浮点值

我正在使用SQL Server,在其中一个表中我有浮动可空列.当我在Microsoft SQL Server Management Studio中查看该值时,我在其中一个记录中的值为1.3.我还有客户端应用程序通过实体框架(EF)从数据库获取数据,并且它具有该列的相应可空双(双?)属性.现在当我从数据库中获取值时,它的值为1.2999999523162842.

所有这些记录(超过100万)将用于插值,外推和计算,任何最小偏差都将成为重要值.因此,客户端的所有值都必须匹配数据库中的值.

我不能在客户端舍入到第一个十进制数,因为在数据库中有两个,三个,四个或更多小数点的值.

我的问题是如何通过EF从数据库加载数据库后,确保数据库中的所有值都是相同的值?

非常感谢提前.

.net c# sql-server entity-framework

1
推荐指数
1
解决办法
1496
查看次数

TDD功能测试

我应该为所有嵌套方法编写单元测试,还是为调用者编写一个测试就足够了?

例如:

void Main()
{
    var x = new A().AFoo();
}

public class A
{
    public int AFoo()
    {        
        // some logic
        var x = new B().BFoo();

        // might have some logic

        return x;
    }
}

public class B
{
    public int BFoo()
    {
        // some logic
        return ???;
    }
}
Run Code Online (Sandbox Code Playgroud)

这是否足以为Main()方法编写单元测试,或者我需要为Main,A.AFoo(),B.BFoo()方法编写测试?我该走多远?

提前致谢.

testing tdd unit-testing

1
推荐指数
1
解决办法
238
查看次数