如何初始化和加载MCR [英] How to initialize and load MCR

查看:236
本文介绍了如何初始化和加载MCR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Win32控制台应用程序中引入了从MATLAB生成的C ++共享库。 MATLAB程序需要2-3秒在MATLAB中执行,但控制台应用程序需要11-12秒执行。我读这是因为MCR的启动时间,我相信在MCR初始化后,它必须采取相同的时间,因为它需要matlab。那么如何加载或初始化MCR,以便它总是在RAM或缓存中,这样将需要2-3秒的控制台应用程序运行?我应该做一个无限循环,使MCR连续加载??我在Windows操作系统上工作,我从PHP调用控制台应用程序。任何教程或链接?

I incorporated C++ shared library generated from MATLAB in a Win32 console application. The MATLAB program takes 2-3 sec to execute in MATLAB but the console application takes 11-12 seconds to execute. I read this is because of the start up time of MCR and I believe after the MCR is initialized it must take same time as it takes in matlab. So how can I load or initialize the MCR so that it is always in the RAM or cache so that it will take 2-3 sec for the console application to run? Should I have to make an infinity loop so that the MCR is loaded continously?? I am working on Windows OS and I am calling the console application from PHP. Any tutorials or link for that?

我添加了MCR_CACHE_ROOT作为指向文件夹(非临时)的环境变量。我的控制台应用程序代码如下:

I have added the MCR_CACHE_ROOT as an environment variable which points to a folder(not temporary). My console application code is as follows:

// shoes_shared.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "shoes_sharedlibrary.h"
#include <iostream>
#include <string.h>
#include "mex.h"



using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
    /* Call the MCR and library initialization functions */
 //const char *pStrings[]={"-nojvm","-nojit"};
 //   if (!mclInitializeApplication(pStrings,2))
 //   {
 //       fprintf(stderr, "Could not initialize MCR for the application.\n");
 //       return -1;
 //   }

if (!shoes_sharedlibraryInitialize())
{

    exit(1);
}



     mwArray img(argv[1]); 

     double wt1 = _tstof(argv[2]);
     mwArray C(wt1);
    double wt2 = _tstof(argv[3]);
    mwArray F(wt2);
    double wt3 = _tstof(argv[4]);
    mwArray T(wt3);
    double wt4 = _tstof(argv[5]);
    mwArray S(wt4);



           test_shoes(img,C,F,T,S);
            //shoes_sharedlibraryTerminate();
            //mclTerminateApplication();
            return 0;
}

我已经评论过上面的想法,它会使它更快,但没有运气。任何帮助?

I have commented the lines above thinking that it will make it faster but no luck. Any help?

推荐答案

尝试将MCR和所有共享库依赖项放到RAM驱动器。

Try to put MCR and all shared library dependencies to RAM drive.

有很多方法来创建RAM驱动器。我建议使用 ImDisk

There are lot of ways to create RAM drive. I would suggest to use ImDisk

这篇关于如何初始化和加载MCR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆