ASP.NET MVC性能(ASP.NET MVC Performance)
我发现一些野蛮言论,ASP.NET MVC比ASP.NET WebForms快30倍。 什么真正的性能差异在哪里,这是衡量和什么是性能优势。
这是为了帮助我考虑从ASP.NET WebForms移植到ASP.NET MVC。
I found some wild remarks that ASP.NET MVC is 30x faster than ASP.NET WebForms. What real performance difference is there, has this been measured and what are the performance benefits.
This is to help me consider moving from ASP.NET WebForms to ASP.NET MVC.
原文:https://stackoverflow.com/questions/43743
更新时间:2021-09-02 20:09
最满意答案
#include <boost/thread/tss.hpp> static boost::thread_specific_ptr< MyClass> instance; if( ! instance.get() ) { // first time called by this thread // construct test element to be used in all subsequent calls from this thread instance.reset( new MyClass); } instance->doSomething();
#include <boost/thread/tss.hpp> static boost::thread_specific_ptr< MyClass> instance; if( ! instance.get() ) { // first time called by this thread // construct test element to be used in all subsequent calls from this thread instance.reset( new MyClass); } instance->doSomething();
相关问答
更多-
速度取决于TLS的实施。 是的,TLS可以像查找指针一样快,这是正确的。 具有内存管理单元的系统甚至可以更快。 对于指针查找,您需要调度程序的帮助。 调度程序必须 - 在任务开关上 - 更新指向TLS数据的指针。 实现TLS的另一种快速方法是通过内存管理单元。 这里的TLS被视为与任何其他数据一样,除了TLS变量分配在一个特殊的段中。 调度程序将在任务切换时将正确的内存块映射到任务的地址空间。 如果调度程序不支持任何这些方法,则编译器/库必须执行以下操作: 获取当前的ThreadId 采取信号量 通过Thr ...
-
#include
static boost::thread_specific_ptr< MyClass> instance; if( ! instance.get() ) { // first time called by this thread // construct test element to be used in all subsequent calls from this thread instance.reset( new ... -
Python中的“线程本地存储”是什么,为什么需要它?(What is “thread local storage” in Python, and why do I need it?)[2022-11-07]
在Python中,所有东西都是共享的,除了函数局部变量(因为每个函数调用获得自己的一组本地线程,线程总是单独的函数调用)。即使这样,只有变量本身(引用对象的名称)是功能的本地; 对象本身总是全局的,任何东西都可以引用它们。 在这方面,特定线程的Thread对象不是特殊对象。 如果您将Thread对象存储在所有线程都可以访问的位置(如全局变量),则所有线程都可以访问该Thread对象。 如果你想原子地修改你不是在这个相同的线程中创建的任何东西 ,并且没有其他线程可以在任何地方存储,你必须通过锁来保护它。 所有 ... -
Thread.new do Thread.current[:foo]="bar" t1=Thread.new(Thread.current) do |parent| puts parent[:foo] ? parent[:foo] : 'nothing' end.join end.join #=> bar 更新: 在irb中尝试这个: thread_ext.rb class Thread def self.another_new(*args) parent = Th ...
-
线程本地存储macosx(thread local storage macosx)[2023-11-25]
我相信这个页面只是一个Apple标准GCC手册上的样式表。 在Mac OS X中注意.so而不是.dylib 。 所以Mac上的gcc完全有可能不支持__thread 。 您需要手动使用pthread_setspecific 。 ( 此问题已作为错误提交 。) I believe that page is just an Apple stylesheet slapped on the standard GCC manual. Notice the .so instead of .dylib in Mac O ... -
线程本地存储(Thread Local Storage)[2022-12-05]
函数的局部变量对于运行该函数的每个线程都是唯一的。 这可以在TLS的帮助下完成,正如已经提到的那样,每个线程都是本地的。 如果你想在线程之间共享一些数据,有几个选择从使用全局或静态变量到内存映射文件等等。如果你需要在线程之间共享数据,还要检查线程同步。 下图说明了TLS的工作原理。 有关更多信息,请查看MSDN 。 替代文字http://i.msdn.microsoft.com/dynimg/IC495837.png The local variables of a function are unique ... -
您不应该将ThreadLocal与并行任务一起使用,如果您有需要处理的资源,除非您在创建对象时跟踪创建的对象,否则很难自行清理。 这是因为在ThreadPool上创建了任务,因此无法保证再次返回同一个线程来执行清理工作1 。 处理此问题的更好方法是使用Parallel.For或Parallel.ForEach ,它接收lambda,该lambda创建一个与任务绑定的对象,并且一次只能由一个线程使用(名为localInit和localFinally )。 Parallel.ForEach(GetSomeDat ...
-
在MSDN上阅读本文 ,文章中有示例代码的链接。 Read this on MSDN, there is a link to example code in the article.
-
在这种情况下,您使用线程本地存储是安全的。 没有两个线程将共享相同的本地存储(因此它的线程本地)。 因此,两个并发请求不会踩踏其他数据。 几个其他评论虽然 请避免使用Thread.Abort 。 这是一个非常危险的操作,在这里真的不需要。 线程将在之后结束语句。 更好的方法是创建一个包含UserId作为本地字段的后台操作的类。 每个请求都会获得一个新的类实例。 这是将数据传递给后台任务的更简单方法 In this case your use of thread local storage is safe. ...
-
在C / C ++中实现线程局部存储(TLS)(多线程)(Implementation of Thread-local storage (TLS) in C/C++ (multithreading))[2022-09-04]
TLS在每个线程对象中实现为数据数组。 每个线程对象都有自己的数组本地副本,每个数组的大小相同。 当您将全局/静态变量声明为使用TLS时,它与这些数组的索引相关联(这就是编译器/操作系统知道要分配多少个数组插槽的方式)。 因此,当您在运行时访问变量时,您实际上是访问正在访问变量的线程上下文的数据数组中的关联槽。 TLS可能是C ++ 11中的一个新的本机功能,但它已经在各种OS API中提供了很长时间。 TLS在Windows上使用Win32 API TlsAlloc() , TlsGetValue() , ...