Write binary file to disk super fast in MEX

17 views (last 30 days)
rinkert
rinkert on 29 Nov 2021
Commented: rinkert on 30 Nov 2021
I need to write a large array of data to disk as fast as possible. From MATLAB I can do that with fwrite:
function writeBinaryFileMatlab(data)
fid = fopen('file_matlab.bin', 'w');
fwrite(fid, data, class(data));
fclose(fid);
end
Now I have to do the same, but from a MEX file called by MATLAB. So I setup a MEX function that can write to file using either fstream or fopen (Inspired by the results of this SO post). This is however much slower than calling fwrite from MATLAB, as you can see below. Why is this the case, and what can I do to increase my write speed from the MEX function. Find up to date src code for these tests here https://github.com/rick3rt/saveBinaryDataMex
#include "mex.h"
#include <windows.h>
#include <iostream>
#include <stdio.h>
#include <fstream>
using namespace std;
void writeBinFile(int16_t *data, size_t size)
{
FILE *fID;
fID = fopen("file_fopen.bin", "wb");
fwrite(data, sizeof(int16_t), size, fID);
fclose(fID);
}
void writeBinFileFast(int16_t *data, size_t size)
{
ofstream file("file_ostream.bin", std::ios::out | std::ios::binary);
file.write((char *)&data[0], size * sizeof(int16_t));
file.close();
}
void writeBinFileFastWindows(const char *fname, int16_t *data, size_t size)
{
HANDLE file = CreateFileA(fname,
GENERIC_WRITE,
0,
NULL,
CREATE_ALWAYS,
FILE_FLAG_SEQUENTIAL_SCAN,
NULL);
WriteFile(file, data, sizeof(int16_t) * size, NULL, NULL);
CloseHandle(file);
}
void mexFunction(int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[])
{
const mxArray *mxPtr = prhs[0];
size_t nelems = mxGetNumberOfElements(mxPtr);
int16_t *ptr = (int16_t *)mxGetData(mxPtr);
#ifdef USE_OFSTREAM
writeBinFileFast(ptr, nelems);
#elif defined USE_WINDOWS
writeBinFileFastWindows(fname, ptr, nelems);
#else
writeBinFile(ptr, nelems);
#endif
}
If I time this with
eval('mex -R2018a -Iinclude -DUSE_OFSTREAM src/*.cpp -output bin/writefast_ofstream')
eval('mex -R2018a -Iinclude -DUSE_WINDOWS src/*.cpp -output bin/writefast_windows')
eval('mex -R2018a -Iinclude src/*.cpp -output bin/writefast_fwrite')
for k = 1:8
sizeBytes = 2^k * 1024 * 1024;
fprintf('Generating data of size %i MB\n', sizeBytes / 2^20)
M = sizeBytes / 2; % 2 bytes for an int16
sizeMB(k) = sizeBytes / 2^20;
data = int16(rand(M, 1) * 100);
fprintf('TESTING: write ofstream: ')
t_ofstream(k) = timeit(@() writefast_ofstream('ofstream_test.bin', data), 0);
fprintf('%.2f ms\n', t_ofstream(k) * 1e3)
fprintf('TESTING: write windows: ')
t_windows(k) = timeit(@() writefast_windows('windows_test.bin', data), 0);
fprintf('%.2f ms\n', t_windows(k) * 1e3)
fprintf('TESTING: write fwrite: ')
t_fwrite(k) = timeit(@() writefast_fwrite('fwrite_test.bin', data), 0);
fprintf('%.2f ms\n', t_fwrite(k) * 1e3)
fprintf('TESTING: write matlab: ')
t_matlab(k) = timeit(@() writeBinaryFileMatlab('matlab_test.bin', data));
fprintf('%.2f ms\n', t_matlab(k) * 1e3)
data_read = readBinFile('windows_test.bin', [M 1], '*int16');
assert(nnz(data_read - data) == 0, 'Test failed! Data written and read not equal.')
end
figure(14); clf;
plot((sizeMB), t_matlab * 1e3)
hold on
plot((sizeMB), t_ofstream * 1e3)
plot((sizeMB), t_windows * 1e3)
plot((sizeMB), t_fwrite * 1e3)
legend('Matlab', 'ofstream', 'windows', 'fwrite')
xticks(sizeMB)
ylabel('time (ms)')
ylabel('Data size (MB)')
clear data
save('test_result')
My mex results are a lot slower than the Matlab fwrite. Why is this?
Compiler log
Found installed compiler 'Microsoft Visual C++ 2017'.
Set PATH = C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\HostX64\x64\;C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\VC\vcpackages;C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE;C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools;C:\Program Files (x86)\Windows Kits\10\\Bin\10.0.19041.0\x64;C:\Program Files (x86)\Windows Kits\10\\Bin\10.0.19041.0\x86;C:\Program Files (x86)\Windows Kits\10\\Bin\x64;C:\Program Files (x86)\Windows Kits\10\\Bin\x86;;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\libnvvp;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Microsoft Windows Performance Toolkit\;C:\PROGRA~1\MATLAB\R2020a\runtime\win64;C:\PROGRA~1\MATLAB\R2020a\bin;C:\Program Files\MATLAB\R2020a\runtime\win64;C:\Program Files\MATLAB\R2020a\bin;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\dotnet\;C:\Program Files\NVIDIA Corporation\Nsight Compute 2020.3.1\;C:\Users\rwaasdorp1\AppData\Local\Programs\Python\Python39;C:\Users\rwaasdorp1\AppData\Local\Programs\Microsoft VS Code;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\bin\\..\extras\CUPTI\lib64;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\libnvvp;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Microsoft Windows Performance Toolkit\;C:\Program Files\MATLAB\R2020a\runtime\win64;C:\Program Files\MATLAB\R2020a\bin;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\dotnet\;C:\Program Files\NVIDIA Corporation\Nsight Compute 2020.3.1\;C:\Users\rwaasdorp1\AppData\Local\Programs\Python\Python39;C:\Users\rwaasdorp1\AppData\Local\Programs\Microsoft VS Code;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\bin\\..\extras\CUPTI\lib64;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\NVID
Set INCLUDE = C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\atlmfc\include;C:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\ucrt;C:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\shared;C:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\um;C:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\winrt;C:\Program Files\MATLAB\R2020a\extern\include;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\atlmfc\include;C:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\ucrt;C:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\shared;C:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\um;C:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\winrt;C:\Program Files\MATLAB\R2020a\extern\include;
Set LIB = C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\lib\x64;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\atlmfc\lib\x64;C:\Program Files (x86)\Windows Kits\10\\Lib\10.0.19041.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\10\\lib\10.0.19041.0\um\x64;C:\Program Files\MATLAB\R2020a\lib\win64;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\lib\x64;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\atlmfc\lib\x64;C:\Program Files (x86)\Windows Kits\10\\Lib\10.0.19041.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\10\\lib\10.0.19041.0\um\x64;C:\Program Files\MATLAB\R2020a\lib\win64;
Set LIBPATH = C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\lib\x64;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\atlmfc\lib\x64;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\lib\x64;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\atlmfc\lib\x64;
Options file details
-------------------------------------------------------------------
Compiler location: C:\Program Files\Microsoft Visual Studio\2022\Community\
Options file: C:\Users\rwaasdorp1\AppData\Roaming\MathWorks\MATLAB\R2020a\mex_C++_win64.xml
CMDLINE200 : link /nologo /manifest /DLL /EXPORT:mexFunction /EXPORT:mexfilerequiredapiversion C:\Users\RWAASD~1\AppData\Local\Temp\mex_29341090340414_4136\main.obj C:\Users\RWAASD~1\AppData\Local\Temp\mex_29341090340414_4136\saveFunctions.obj C:\Users\RWAASD~1\AppData\Local\Temp\mex_29341090340414_4136\cpp_mexapi_version.obj /LIBPATH:"C:\Program Files\MATLAB\R2020a\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libMatlabDataArray.lib libMatlabEngine.lib /out:"C:\mypath\saveBinaryDataMex\saveBinData.mexw64"
CMDLINE250 : mt -outputresource:"C:\mypath\saveBinaryDataMex\saveBinData.mexw64";2 -manifest "C:\mypath\saveBinaryDataMex\saveBinData.mexw64.manifest"
CMDLINE300 : del "C:\mypath\saveBinaryDataMex\saveBinData.exp" "C:\mypath\saveBinaryDataMex\saveBinData.lib" "C:\mypath\saveBinaryDataMex\saveBinData.mexw64.manifest" "C:\mypath\saveBinaryDataMex\saveBinData.ilk"
COMPILER : cl
COMPFLAGS : /Zp8 /GR /W3 /EHs /nologo /MD
COMPDEFINES : /DUSE_WINDOWS /DMX_COMPAT_64 /DMATLAB_MEXCMD_RELEASE=R2018a /DUSE_MEX_CMD /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE
MATLABMEX : /DMATLAB_MEX_FILE
OPTIMFLAGS : /O2 /Oy- /DNDEBUG
INCLUDE : -I"include" -I"C:\Program Files\MATLAB\R2020a\extern\include" -I"C:\Program Files\MATLAB\R2020a\simulink\include"
DEBUGFLAGS : /Z7
LINKER : link
LINKFLAGS : /nologo /manifest
LINKTYPE : /DLL
LINKEXPORT : /EXPORT:mexFunction
LINKEXPORTVER : /EXPORT:mexFunction /EXPORT:mexfilerequiredapiversion
LINKLIBS : /LIBPATH:"C:\Program Files\MATLAB\R2020a\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libMatlabDataArray.lib libMatlabEngine.lib
LINKDEBUGFLAGS : /debug /PDB:"C:\mypath\saveBinaryDataMex\saveBinData.mexw64.pdb"
LINKOPTIMFLAGS :
OBJEXT : .obj
LDEXT : .mexw64
SETENV : set COMPILER=cl
set COMPFLAGS=/c /Zp8 /GR /W3 /EHs /nologo /MD /DUSE_WINDOWS /DMX_COMPAT_64 /DMATLAB_MEXCMD_RELEASE=R2018a /DUSE_MEX_CMD /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /DMATLAB_MEX_FILE
set OPTIMFLAGS=/O2 /Oy- /DNDEBUG
set DEBUGFLAGS=/Z7
set LINKER=link
set LINKFLAGS=/nologo /manifest /export:%ENTRYPOINT% /DLL /LIBPATH:"C:\Program Files\MATLAB\R2020a\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libMatlabDataArray.lib libMatlabEngine.lib /EXPORT:mexFunction
set LINKDEBUGFLAGS=/debug /PDB:"%OUTDIR%%MEX_NAME%.mexw64.pdb"
set NAME_OUTPUT=/out:"%OUTDIR%%MEX_NAME%%MEX_EXT%"
VCROOT : C:\Program Files\Microsoft Visual Studio\2022\Community
SDKROOT : C:\Program Files (x86)\Windows Kits\10\
VSINSTALLDIR : C:\Program Files\Microsoft Visual Studio\2022\Community
VCINSTALLDIR : C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705
VCVARSALLDIR : C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build
KITSROOT : C:\Program Files (x86)\Windows Kits\10\
SDKVERSION : 10.0.19041.0
MATLABROOT : C:\Program Files\MATLAB\R2020a
ARCH : win64
SRC : "C:\mypath\saveBinaryDataMex\src\main.cpp";"C:\mypath\saveBinaryDataMex\src\saveFunctions.cpp";"C:\Program Files\MATLAB\R2020a\extern\version\cpp_mexapi_version.cpp"
OBJ : C:\Users\RWAASD~1\AppData\Local\Temp\mex_29341090340414_4136\main.obj;C:\Users\RWAASD~1\AppData\Local\Temp\mex_29341090340414_4136\saveFunctions.obj;C:\Users\RWAASD~1\AppData\Local\Temp\mex_29341090340414_4136\cpp_mexapi_version.obj
OBJS : C:\Users\RWAASD~1\AppData\Local\Temp\mex_29341090340414_4136\main.obj C:\Users\RWAASD~1\AppData\Local\Temp\mex_29341090340414_4136\saveFunctions.obj C:\Users\RWAASD~1\AppData\Local\Temp\mex_29341090340414_4136\cpp_mexapi_version.obj
SRCROOT : C:\mypath\saveBinaryDataMex\src\main
DEF : C:\Users\RWAASD~1\AppData\Local\Temp\mex_29341090340414_4136\saveBinData.def
EXP : "C:\mypath\saveBinaryDataMex\saveBinData.exp"
LIB : "C:\mypath\saveBinaryDataMex\saveBinData.lib"
EXE : "C:\mypath\saveBinaryDataMex\saveBinData.mexw64"
ILK : "C:\mypath\saveBinaryDataMex\saveBinData.ilk"
MANIFEST : "C:\mypath\saveBinaryDataMex\saveBinData.mexw64.manifest"
TEMPNAME : C:\mypath\saveBinaryDataMex\saveBinData
EXEDIR : C:\mypath\saveBinaryDataMex\
EXENAME : saveBinData
OPTIM : /O2 /Oy- /DNDEBUG
LINKOPTIM :
CMDLINE100_0 : cl /c /Zp8 /GR /W3 /EHs /nologo /MD /O2 /Oy- /DNDEBUG /DUSE_WINDOWS /DMX_COMPAT_64 /DMATLAB_MEXCMD_RELEASE=R2018a /DUSE_MEX_CMD /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE -I"include" -I"C:\Program Files\MATLAB\R2020a\extern\include" -I"C:\Program Files\MATLAB\R2020a\simulink\include" "C:\mypath\saveBinaryDataMex\src\main.cpp" /FoC:\Users\RWAASD~1\AppData\Local\Temp\mex_29341090340414_4136\main.obj
CMDLINE100_1 : cl /c /Zp8 /GR /W3 /EHs /nologo /MD /O2 /Oy- /DNDEBUG /DUSE_WINDOWS /DMX_COMPAT_64 /DMATLAB_MEXCMD_RELEASE=R2018a /DUSE_MEX_CMD /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE -I"include" -I"C:\Program Files\MATLAB\R2020a\extern\include" -I"C:\Program Files\MATLAB\R2020a\simulink\include" "C:\mypath\saveBinaryDataMex\src\saveFunctions.cpp" /FoC:\Users\RWAASD~1\AppData\Local\Temp\mex_29341090340414_4136\saveFunctions.obj
CMDLINE100_2 : cl /c /Zp8 /GR /W3 /EHs /nologo /MD /O2 /Oy- /DNDEBUG /DUSE_WINDOWS /DMX_COMPAT_64 /DMATLAB_MEXCMD_RELEASE=R2018a /DUSE_MEX_CMD /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE -I"include" -I"C:\Program Files\MATLAB\R2020a\extern\include" -I"C:\Program Files\MATLAB\R2020a\simulink\include" "C:\Program Files\MATLAB\R2020a\extern\version\cpp_mexapi_version.cpp" /FoC:\Users\RWAASD~1\AppData\Local\Temp\mex_29341090340414_4136\cpp_mexapi_version.obj
-------------------------------------------------------------------
Building with 'Microsoft Visual C++ 2017'.
cl /c /Zp8 /GR /W3 /EHs /nologo /MD /O2 /Oy- /DNDEBUG /DUSE_WINDOWS /DMX_COMPAT_64 /DMATLAB_MEXCMD_RELEASE=R2018a /DUSE_MEX_CMD /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE -I"include" -I"C:\Program Files\MATLAB\R2020a\extern\include" -I"C:\Program Files\MATLAB\R2020a\simulink\include" "C:\mypath\saveBinaryDataMex\src\main.cpp" /FoC:\Users\RWAASD~1\AppData\Local\Temp\mex_29341090340414_4136\main.obj
main.cpp
cl /c /Zp8 /GR /W3 /EHs /nologo /MD /O2 /Oy- /DNDEBUG /DUSE_WINDOWS /DMX_COMPAT_64 /DMATLAB_MEXCMD_RELEASE=R2018a /DUSE_MEX_CMD /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE -I"include" -I"C:\Program Files\MATLAB\R2020a\extern\include" -I"C:\Program Files\MATLAB\R2020a\simulink\include" "C:\mypath\saveBinaryDataMex\src\saveFunctions.cpp" /FoC:\Users\RWAASD~1\AppData\Local\Temp\mex_29341090340414_4136\saveFunctions.obj
saveFunctions.cpp
C:\mypath\saveBinaryDataMex\src\saveFunctions.cpp(26): warning C4267: 'argument': conversion from 'size_t' to 'DWORD', possible loss of data
cl /c /Zp8 /GR /W3 /EHs /nologo /MD /O2 /Oy- /DNDEBUG /DUSE_WINDOWS /DMX_COMPAT_64 /DMATLAB_MEXCMD_RELEASE=R2018a /DUSE_MEX_CMD /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE -I"include" -I"C:\Program Files\MATLAB\R2020a\extern\include" -I"C:\Program Files\MATLAB\R2020a\simulink\include" "C:\Program Files\MATLAB\R2020a\extern\version\cpp_mexapi_version.cpp" /FoC:\Users\RWAASD~1\AppData\Local\Temp\mex_29341090340414_4136\cpp_mexapi_version.obj
cpp_mexapi_version.cpp
link /nologo /manifest /DLL /EXPORT:mexFunction /EXPORT:mexfilerequiredapiversion C:\Users\RWAASD~1\AppData\Local\Temp\mex_29341090340414_4136\main.obj C:\Users\RWAASD~1\AppData\Local\Temp\mex_29341090340414_4136\saveFunctions.obj C:\Users\RWAASD~1\AppData\Local\Temp\mex_29341090340414_4136\cpp_mexapi_version.obj /LIBPATH:"C:\Program Files\MATLAB\R2020a\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libMatlabDataArray.lib libMatlabEngine.lib /out:"C:\mypath\saveBinaryDataMex\saveBinData.mexw64"
Creating library C:\mypath\saveBinaryDataMex\saveBinData.lib and object C:\mypath\saveBinaryDataMex\saveBinData.exp
mt -outputresource:"C:\mypath\saveBinaryDataMex\saveBinData.mexw64";2 -manifest "C:\mypath\saveBinaryDataMex\saveBinData.mexw64.manifest"
Microsoft (R) Manifest Tool
Copyright (c) Microsoft Corporation.
All rights reserved.
del "C:\mypath\saveBinaryDataMex\saveBinData.exp" "C:\mypath\saveBinaryDataMex\saveBinData.lib" "C:\mypath\saveBinaryDataMex\saveBinData.mexw64.manifest" "C:\mypath\saveBinaryDataMex\saveBinData.ilk"
MEX completed successfully.
  4 Comments
rinkert
rinkert on 30 Nov 2021
I have experimented with 'W' and 'w' in the past in the fopen function of Matlab, and did not notice any change in write speed. I will test again later. Or do you mean to use W in the fopen C function? I have some input from SO as well that I am gonna test later: https://stackoverflow.com/questions/70126690/write-binary-file-to-disk-super-fast-in-mex

Sign in to comment.

Answers (0)

Categories

Find more on Write C Functions Callable from MATLAB (MEX Files) in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by