A portable device can identify cancer tissue in 10 seconds, according to scientists at the University of Texas.
They say this could be surgery to eliminate a tumor faster, more securely and more accurately.
And they hope that it will avoid the "heartbeat" of leaving cancer.
The tests, published in Science Translational Medicine, suggest that the technology is accurate to 96% of the time.
The MasSpec pen benefits from the unique metabolism of cancer cells.
Your furious effort to grow and spread means that their inner chemistry is very different from that of healthy tissue.
How it works
The penis is touched with suspected cancer and releases a small droplet of water.
The chemicals within the living cells move into the droplet, which is then collected again the pen for analysis.
The pen is inserted into a mass spectrometer - a kit that can measure the mass of thousands of chemicals every second.
It generates a chemical footprint that informs physicians that they are looking for healthy tissue or cancer.
The challenge for surgeons is to find the border between cancer and normal tissue.
In some tumors, it is obvious, but in others, the boundary between healthy and diseased tissues may be blurred.
The pen should help doctors ensure that no cancer is left behind.
Remove too little tissue, and all remaining cancer cells will turn into another tumor. But take too much, and you can cause damage, especially in organs such as the brain.
Livia Eberlin, an assistant of chemistry at the University of Texas, Austin, said the BBC: "What is exciting about this technology is how clearly it meets a clinical need.
"The tool is stylish and simple and can be in the hands of the surgeons in a short time."
The technology was tested for 253 samples as part of the study. The plan is to continue the test to refine the unit before it tries it during operation next year.
The pen currently analyzes a 1.5 mm (0.06 inch) piece of fabric, but researchers have already developed more refined pens and should be able to consider a finer piece of 0.6 mm wide fabric.
While the pen itself is cheap, the mass spectrometer is expensive and bulky.
Dr. Eberlin said, "The roadblock is, of course, the mass spectrometer.
"We are currently seeing a mass spectrometer that is somewhat smaller, cheaper and suitable for this application that can be rolled into the rooms."
Dr. James Suliburk, one of the researchers and the head of endocrine surgery at Baylor College of Medicine, said, "Whenever we can offer the patient a more precise operation, faster surgery, or safer surgery, we still want to do that
"This technology makes all three".
The MasSpec Pen is the last attempt to improve the accuracy of surgery.
A team of Imperial College London developed a knife that "smells" the tissue it cuts to determine if it removes cancer.
And a team from Harvard used lasers to analyze the amount of brain tumor analyze.
Dr. Aine McCarthy of Cancer Research UK said, "Exciting research like this has the potential to speed up the rate at which doctors can determine whether a tumor is cancer or not and know its characteristics.
"Collecting this kind of information quickly during surgery could help doctors to fit the best treatment options for patients earlier."