I am using google benchmark to test performances of two algorithms. However, benchmark_out command seems to not work for me.
1) flags --benchmart_out=/home/knn.json --benchmark_format=json give error invalid file name: '/home/knn.json
2) flags --benchmart_out=./knn.json --benchmark_format=json successfully runs the benchmark with console log but does not create .json.
Is there anything wrong with the flag input given?
Related
I'd like some advice on what vocabulary to use to describe the following. Having the right vocabulary will allow me to search for tools and ideas related to the concept
I'd like to say a script is SomeWord if it is expected to produce the same output no matter where it is run.
For example, the following script is not SomeWord:
#!/bin/bash
ls ~
because of course it depends on where it is executed.
Whereas the following (if it runs without error) is expected to always produce the same output:
#!/bin/bash
echo "hello, world"
A more useful example would be something that loads and runs a docker or singularity container in a way that guarantees that a very particular container image is being used. For example by retrieving the singularity image by its content-hash.
The advantages of SomeWord scripts are: (a) they may be safely run on a remote system without worrying about the environment and (b) their outputs may be cached.
The best I can think of would be "deterministic" or some variation on "environment independent" or "reproducible".
Any container should be able to do this, as that is a big part of why the tech developed in the first place. Environment managers like conda can also do this to a certain extent, but because it's just modifying the host environment it's possible to be using non-conda binaries without realizing it.
If I run the example code below, I get an invalid file identifier error in Matlab:
for i = 1:99999
fid = fopen('test.txt','w');
fprintf(fid,'%s', 'Hello World!\r\n');
fclose(fid);
delete('test.txt');
end;
??? Error using ==> fprintf
Invalid file identifier. Use fopen to generate a valid file identifier.
The interesting thing is, that if I decrease the number of loops, I don't get the error. I researched the problem, and it seems that none of the usual issues that cause the error (Wrong File Path, Corrupt File, File doesn't exist, File already in use) are the culprits, because it works if I change the loops to 10 instead of 99999.
Upon further research, Matlab Forum Post, it seems the problem might be quota related (I think quotas have to do with the OS where the OS, Windows 10 in my case doesn't allow a program to write files after a certain amount of them have been written by the same program?).
How would one increase the quota? Is there a work around? I use Matlab 2010a on Windows 10.
I have also attempted running Matlab in administrator mode with no success.
I'm assuming permissions are correct and disk space is not a problem, but you should check fopen's output nevertheless to get more info or some try-catch which calls ferror(fid) for additional data (note the absence of the semicolon, obviously).
[fid,msg]=fopen('test.txt','w')
If it IS quota related you should be able to disable it in your hard drive's properties, as shown in the image below (it's in spanish, but you should get the idea). Just right click in the unit and access Properties->Disk Quota->Show Configuration and disable it if it isn't already.
GUI location of the disk quota
I am loading about 200k text files in Spark using input = sc.wholeTextFiles(hdfs://path/*)
I then run a println(input.count)
It turns out that my spark shell outputs a ton of text (which are the path of every file) and after a while it just hangs without returning my result.
I believe this may be due to the amount of text outputted by wholeTextFiles. Do you know of any way to run this command silently? or is there a better workaround?
Thanks!
How large are your files?
From the wholeTextFiles API:
Small files are preferred, large files are also allowable, but may
cause bad performance.
In conf/log4j.properties, you can suppress excessive logging, like this:
# Set everything to be logged to the console
log4j.rootCategory=ERROR, console
That way, you'll get back only res to the repl, just like in the Scala (the language) repl.
Here are all other logging levels you can play with: log4j API.
Question
I want it to 'listen' to the standard input stream in a running (compiled) Matlab executable.
This is how I believe it is done in c or a similar language:
#include stdio.h
fgets(line, 256, stdin)
Or more elaborately, it it can be used as such:
if (!fgets(line, 256, stdin))
return;
if (line[0] == '\n')
continue;
sscanf(line, "%s", command);
Answer
For completeness I will leave the background and notes intact, but with the help of Amro and EitanT I have managed to work it out.
Background
I have found how to do this in other languages, and here are some instructions for the compilation process.
However, I have not found anywhere how to 'listen' to the input in Matlab.
The closest I have come is this description of C-like IO in Octave, but I cannot make progress with this as I looking for a solution in MATLAB.
Note that altering or wrapping the program that sends the data over the stream is not possible, and that I would prefer a pure MATLAB solution rather than wrapping my entire program. If I were to call a trivial function from MATLAB in a different language that would be ok.
What have I tried?
I tried a few functions from the command window like fgets(0) (fid = 0 seems to be the id corresponding to stdin (as mentioned by #EitanT and seen when trying fopen(0)) )but it just returns:
Operation is not implemented for requested file identifier.
I have also considered using the option in MATLAB to invoke system commands or execute java / perl commands, but so far without luck. I am also not sure whether these would still work after compilation.
Furthermore I attempted to use input('prompt','s') this works when I open the program via cmd, but does not do anything until I hit enter. (Which the program that I listen to of course will never do, in the best case I can get \n at the end of each line).
I also tried out waitinput from File Exchange but I think this is a dead end as it did not catch anything and seems to perform quite poorly.
Notes
I am using Windows 7 and MATLAB 2012b.
I found popen on File Exchange but that does not seem to be available for Windows.
When I simply type something like 'show me' this is properly sent to the standard output stream.
Let me illustrate with a toy example. Consider the following MATLAB function:
greet.m
function greet()
str = input('Enter your name: ','s');
fprintf('Hello %s\n',str)
end
Now lets compile it into a standalone application. Note that if you use the deploytool tool, make sure to choose "Console application" NOT "Windows standalone application" as target. The latter apparently produces an executable where the standard input is connected to the system shell not the MATLAB command prompt..
If you prefer to directly compile it yourself, use the following invocation:
mcc -o hello -W main:hello -T link:exe -N -v greet.m
(For reference, the "Windows app" target issues -W WinMain:hello instead)
Running the executable produces:
C:\> hello
Enter your name: Amro
Hello Amro
where the input from the keyboard is correctly handled.
It turns out that input reads the standard input stream.
The reason why I failed to collect my inputs, is because I was using it as follows:
input('prompt','s')
As a result the string 'prompt' was sent to the program calling my application, and as it considered this an invalid response/request it did not send anything.
I have succeeded in making a small test program, and unlike I suspected before it is NOT a problem that the other application doesn't hit enter after sending a command.
The general solution
This is the way I have my current setup,
while 1
stdin = input('','s'); % Note the empty first argument
if ~isempty(stdin)
stdout = process_input(stdin);
stdout % Displaying the result (And thus sending it to stdout)
end
end
I have a requirement where I need to run the ruby script in WINDOWS and which will have the following command
test.rb
Dir.chdir("C://mtn-2//mtn-2.2//bin//")
system("CadTestNode.bat")
Here am running some tool called mtn tool, once I run this program it will display the following in the output pane
CAD Message Test Node
Select from the following options:
m - Show Menu
c - Create Test Case Connection
a - Execute All Test Cases
t - Terminate All Test Cases
x - Terminate Test Case Connection
s - Set Sequence Number
q - Quit
Enter choice:
After this the script is stucked in between, its asking for the input. My question is, is there any way to provide the input via script itself? Onemore thing, here I need to provide input 2-3 times. Is it possible to automate this kind of scenario as am running some other tool from the ruby script.
Thanks inadvance, waiting for your early reply.
Use pipe (Open3) instead of system and you will be able to read from external program as well as reply to it. Of course, for Windows you will have to install win32-open3 from http://rubyforge.org/projects/win32utils
You can use gets() to get the input, as for the rest (automate) sure, why not. Instead of my_input=gets.chomp do my_input='my predefined actions' and parse it accordingly.